命令行构建解决方案与 Visual Studio 2012 构建

Command line build solution vs Visual Studio 2012 build

我正在创建 CI 构建机器。我使用命令行构建我们的 VS2012 解决方案,其中包含许多项目类型(wpf、表单、MFC、c# 和 c++)。

我使用以下命令行:

call "%VS110COMNTOOLS%\vsvars32.bat"
devenv.com SolutionName.sln /rebuild "Release|Mixed Platforms"

如果我查看构建输出,一切似乎都很好。与我使用 VS 时相同的输出并且 100% 成功。

但是,以这种方式构建的可执行文件在 运行 时出现错误,而使用 Visual Studio 构建的相同解决方案可以完美运行。

错误发生在显示的第一个 WPF 视图的 InitializeComponent 中。错误消息指示无效的版本字符串。我注意到生成的文件有所不同 (xaml)

命令行构建(不工作):Myview.g.cs

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
    if (_contentLoaded) {
        return;
    }
    _contentLoaded = true;
    System.Uri resourceLocater = new System.Uri("/ProjectName;V3.9.1.*;component/Myview.xaml", System.UriKind.Relative);

    #line 1 "..\..\Myview.xaml"
    System.Windows.Application.LoadComponent(this, resourceLocater);

    #line default
    #line hidden
}

VS 2012 构建(工作):Myview.g.cs

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
    if (_contentLoaded) {
        return;
    }
    _contentLoaded = true;
    System.Uri resourceLocater = new System.Uri("/ProjectName;component/Myview.xaml", System.UriKind.Relative);

    #line 1 "..\..\Myview.xaml"
    System.Windows.Application.LoadComponent(this, resourceLocater);

    #line default
    #line hidden
}

我真的不知道 V3.9.1* 为什么以及如何出现在生成的文件中,但这似乎是问题所在。我该如何纠正它?当我使用命令行构建时,.xaml 生成的所有文件都具有相同的错误 V3.9.1*

终于知道了!

我不知道我是否应该知道或者它是否写在文档的某个地方,但我很高兴我终于找到了问题。

在我构建解决方案的 jenkins 作业中,有一个名为 ASSEMBLYVERSION 的字符串参数。我不知道为什么,但似乎 'devenv' 找到了这个变量并决定使用它。

如果我重命名这个变量,devenv 将不会使用它并且一切正常。