【发布时间】:2015-07-31 13:32:40
【问题描述】:
我正在创建 CI 构建机器。我使用命令行来构建我们的 VS2012 解决方案,其中包含许多项目类型(wpf、forms、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*。
【问题讨论】:
-
我会用 msbuild.exe 构建......而不是开发工具。事实上,我尽我所能在构建机器上安装 Visual Studio。
-
更改构建工具并不是真正的答案,MSBuild 还会带来其他问题。我不认为在我们的构建机器上安装 Visual Studio 是一个问题。
-
在构建机器上安装 VS 会安装大量“隐藏”依赖项。使用 msbuild 会迫使您考虑它们(如何获取它们以及如何打包它们)......因为它们通常不在“干净”的机器上。但对每个他/她自己。祝你好运。
-
嗯,好的。很高兴知道。谢谢
标签: c# wpf visual-studio visual-studio-2012 build