gpt4 book ai didi

WPF 应用程序在 vs2k8 中构建,但不在带有 msbuild 的命令行上

转载 作者:行者123 更新时间:2023-12-04 17:42:00 29 4
gpt4 key购买 nike

我有一个相当小的解决方案,其中包括一个 WPF Windows 应用程序。从解决方案构建时,它构建得非常好。我最近将解决方案中包含的项目集成到一个使用 MSBuild 的现有的、更大的命令行构建中。但是,从命令行构建时,出现以下错误:

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

我在我们的根 MSBuild .proj 文件中包含了来自 .NET 3.5 的 WinFX 目标文件,因为它似乎没有包含在其他任何地方:
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />

不过,这似乎没有影响任何事情,而且我仍然遇到错误。据我所知,似乎将 .xaml 文件预编译为 .cs 文件、嵌入和连接资源等的自定义 WPF 构建任务没有运行,这就是 InitializeComponent 和我的 View 中定义的任何控件的原因未找到。我对 不知所措为什么 ,虽然......并且试图通过与 WPF 和 MSBuild 相关的无数搜索结果并没有让我到任何地方。

更新:

将 Microsoft.WinFX.targets 添加到 .csproj 文件似乎会起作用。但是,这样做会导致项目无法在 Visual Studio 2008 中构建。不知何故,VS 为您包含了这些目标......但我不确定如何。有没有人更了解VS如何构建WPF项目?是否有一个主构建文件隐藏在导入适当目标的地方?

最佳答案

发送 msbuild 您的解决方案文件而不是 .csproj 文件有时会有所帮助:

msbuild.exe yoursolution.sln

此外,devenv.exe 本身提供了一个命令行构建,它应该等同于 IDE 体验:
devenv.exe /build yoursolution.sln

关于WPF 应用程序在 vs2k8 中构建,但不在带有 msbuild 的命令行上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1671032/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com