小编mon*_*fer的帖子

Exec powershell.exe挂起msbuild

我目前正在考虑重新设计我们的黑客攻击部署系统,使其更加优雅 - 八达通.在这样做的时候,我正在尝试让VS在运行发布版本时打包一个项目.好吧,我有这个花哨的PowerShell脚本编写和工作,但当我尝试从msbuild脚本EXEC,视觉工作室只是挂起!

起初我怀疑是什么东西在shell中被逃脱了,但是我把它简化得很荒谬,它仍然冻结了.

这是相关的MsBuild代码:

    <PropertyGroup>
      <PowerShellExe Condition=" '$(PowerShellExe)'=='' ">
        %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe
      </PowerShellExe>
    </PropertyGroup>

    <Target Name="AfterBuild" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
      <Exec Command="$(PowerShellExe) -NonInteractive -executionpolicy Unrestricted -command get-childitem" />
    </Target>
Run Code Online (Sandbox Code Playgroud)

它应该做的只是提供一个目录列表.从cmd.exe调用此方法工作正常:

C:\Users\smithj>%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -executionpolicy unrestricted -command dir
Run Code Online (Sandbox Code Playgroud)

试试这个:

msbuild Solution.sln /p:Configuration=Release
Run Code Online (Sandbox Code Playgroud)

得到我这个:

AfterBuild:
  "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\\tf.exe" che
  ckout Package.nuspec
  Package.nuspec

        %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe
       -NonInteractive -executionpolicy Unrestricted -command dir

  Windows PowerShell
  Copyright (C) 2009 Microsoft Corporation. All rights reserved.
Run Code Online (Sandbox Code Playgroud)

在那之后,它永远挂起.欢迎任何建议.

msbuild powershell hang visual-studio-2010

19
推荐指数
1
解决办法
3186
查看次数

在C#中二进制反序列化期间更改类型

我们公司的解决方案之一消耗第三方服务.通过XML消息传递完成通信.在我们的最后,我们基于它们提供给我们的XML模式生成要使用的类,并且在某些时候我们将这些类型中的一些序列化为数据库中的二进制blob以供以后使用.

问题出现在第三方公司将其中一个字段从布尔值更改为整数类型的位置.现在,当我们尝试对已经存在的数据进行反序列化时,我们可以预见到会发生类型转换异常(无法从布尔值转换为整数).

我的问题是 - 我们如何使用旧的布尔类型反序列化我们数据库中的现有数据以将其转换为新的整数类型?

我已经尝试了很多东西 - 其中包括反思和实现ISerializable,但到目前为止还没有任何东西被淘汰.理想的解决方案是实现ISerializable,但是在尝试反序列化现有数据时遇到"未找到成员"错误,因为它已经仅使用Serializable属性进行了序列化.

欢迎任何建议!

编辑:添加一些代码以清楚地展示我的问题.

namespace ClassLibrary
{
    [Serializable]
    public class Foo //: ISerializable
    {
        public bool Bar { get; set; }

        public Foo() { }

        //[OnDeserializing()]
        //internal void OnDeserializingMethod(StreamingContext context)
        //{
        //    Bar = 10;
        //}

        //public Foo(SerializationInfo info, StreamingContext context)
        //{
        //    Bar = (int)info.GetValue("Bar", typeof(int));
        //}

        //public void GetObjectData(SerializationInfo info, StreamingContext context)
        //{
        //    info.AddValue("Bar", Bar);
        //}
    }
}

namespace ConsoleApplication2
{
    static class Program
    {
        static void Main(string[] args)
        {
            Foo …
Run Code Online (Sandbox Code Playgroud)

c# serialization blob binaryformatter

3
推荐指数
1
解决办法
1753
查看次数