WPF应用程序建立在vs2k8,而不是在命令行瓦特/的MSBuild [英] WPF app builds in vs2k8, but not on command line w/ msbuild

查看:144
本文介绍了WPF应用程序建立在vs2k8,而不是在命令行瓦特/的MSBuild的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当小的解决方案,包括WPF windows应用程序。从溶液中生成时它建立完美的罚款。我最近整合包含在解决方案到现有的,更大的命令行使用的MSBuild建设中的项目。当在命令行中建,但是,我得到以下错误:

I have a fairly small solution that includes a WPF windows application. It builds perfectly fine when built from the solution. I recently integrated the projects contained within the solution into an existing, much larger command line build that uses MSBuild. When built from the command line, however, I get the following errors:

MainWindow.xaml.cs(12,4): error CS0103: The name 'InitializeComponent' does not exist in the current context
View\EngineMonitorView.xaml.cs(12,4): error CS0103: The name 'InitializeComponent' does not exist in the current context
View\HostingEngineView.xaml.cs(12,4): error CS0103: The name 'InitializeComponent' does not exist in the current context
View\MainView.xaml.cs(13,4): error CS0103: The name 'InitializeComponent' does not exist in the current context
View\MainView.xaml.cs(17,52): error CS0103: The name 'gView' does not exist in the current context
View\PerformanceCounterView.xaml.cs(22,4): error CS0103: The name 'InitializeComponent' does not exist in the current context
View\PerformanceCounterView.xaml.cs(117,22): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(118,20): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(127,4): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(138,5): error CS0103: The name 'txtScale' does not exist in the current context
View\PerformanceCounterView.xaml.cs(179,5): error CS0103: The name 'txtLast' does not exist in the current context
View\PerformanceCounterView.xaml.cs(180,5): error CS0103: The name 'txtMin' does not exist in the current context
View\PerformanceCounterView.xaml.cs(181,5): error CS0103: The name 'txtMax' does not exist in the current context
View\PerformanceCounterView.xaml.cs(189,5): error CS0103: The name 'txtAverage' does not exist in the current context
View\PerformanceCounterView.xaml.cs(250,4): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(251,4): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(253,27): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(255,27): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(264,4): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(269,4): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(274,4): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(279,4): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(293,5): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(303,5): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(318,5): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(325,5): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\PerformanceCounterView.xaml.cs(342,4): error CS0103: The name 'cnvsCounterGrid' does not exist in the current context
View\ServerMonitorView.xaml.cs(12,4): error CS0103: The name 'InitializeComponent' does not exist in the current context
View\ServerTreeView.xaml.cs(12,4): error CS0103: The name 'InitializeComponent' does not exist in the current context
View\ServiceDetailView.xaml.cs(12,4): error CS0103: The name 'InitializeComponent' does not exist in the current context
View\ServiceMonitorView.xaml.cs(12,4): error CS0103: The name 'InitializeComponent' does not exist in the current context

我包括WinFX的目标从.NET 3.5的文件中我们的根的MSBuild .proj文件,因为它似乎没有包括其他地方:

I included the WinFX targets file from .NET 3.5 in our root MSBuild .proj file, as it did not appear to be included anywhere else:

<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />

似乎没有影响到什么,不过,我还是遇到了错误。据我所知道的,它出现的自定义WPF建设任务precompile的的.xaml文件到的.cs文件,嵌入和电线的资源等等都没有运行,这也就是为什么在InitializeComponent和定义的控件我的意见都没有发现。我在一个损失为为什么,但...并试图通过相关的WPF和MSBuild的搜索结果中的数以亿计的韦德没有得到我的任何地方。

That did not seem to affect anything, though, and I am still encountering the errors. As far as I can tell, it appears that the custom WPF build tasks that precompile the .xaml files into .cs files, embeds and wires up resources, etc. are not running, which is why InitializeComponent and any controls defined in my views are not found. I am at a loss as to why, though...and trying to wade through the zillions of search results related to WPF and MSBuild is not getting me anywhere.

更新:

添加Microsoft.WinFX.targets到.csproj的文件,好像它会工作。但是,这样做会导致项目失败打造Visual Studio 2008中不知何故中,VS是包括这些目标对你......但我不知道该如何。有谁知道更多关于VS如何构建WPF项目?是否有一个主生成文件藏在什么地方了导入适当的目标?

Adding the Microsoft.WinFX.targets to the .csproj file seems like it would work. However, doing so causes the project to fail to build within Visual Studio 2008. Somehow, VS is including those targets for you...but I am unsure how. Does anyone know more about how VS builds WPF projects? Is there a master build file hiding somewhere that imports the appropriate targets?

推荐答案

发送的MSBuild您的解决方案的文件,而不是你的.csproj文件有时可以帮助:

Send msbuild your solution file instead of your .csproj file can sometimes help:

msbuild.exe yoursolution.sln

此外,devenv.exe的本身就提供了一个命令行构建应该是相当于在-IDE的经验:

Also, devenv.exe itself offers a command-line build that's supposed to be equivalent to the in-IDE experience:

devenv.exe /build yoursolution.sln

这篇关于WPF应用程序建立在vs2k8,而不是在命令行瓦特/的MSBuild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆