Wpf 类型或命名空间名称';应用程序';找不到(是否缺少使用方向或程序集引用?)
我正试图从命令行构建一个WPF应用程序。我正在使用msbuild,但编译时生成失败。我得到这个错误 我试图添加引用程序集,但仍然不起作用。我该怎么办。我不想使用Visual Studio 这是我的密码Wpf 类型或命名空间名称';应用程序';找不到(是否缺少使用方向或程序集引用?),wpf,compiler-errors,reference,msbuild,.net-assembly,Wpf,Compiler Errors,Reference,Msbuild,.net Assembly,我正试图从命令行构建一个WPF应用程序。我正在使用msbuild,但编译时生成失败。我得到这个错误 我试图添加引用程序集,但仍然不起作用。我该怎么办。我不想使用Visual Studio 这是我的密码 using System; using System.Collections.Generic; using System.Windows; namespace WpfTutorialSamples { public partial class App : Application
using System;
using System.Collections.Generic;
using System.Windows;
namespace WpfTutorialSamples
{
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
// Create the startup window
MainWindow wnd = new MainWindow();
// Do stuff here, e.g. to the window
wnd.Title = "Something else";
// Show the window
wnd.Show();
}
}
}
这是xaml代码
<Application x:Class="WpfTutorialSamples.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup">
<Application.Resources></Application.Resources>
</Application>
这是msbuild代码
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Include="App.xaml.cs" />
</ItemGroup>
<Target Name="Build">
<Csc Sources="@(Compile)"/>
</Target>
</Project>
我尝试了几个网站和参考资料来学习,也许每个人都喜欢Visual Studio,但我还没有找到一个可以使用命令行开发的参考资料。通常要从命令行编译项目,我建议使用Visual Studio创建的项目文件。尝试添加框架库的引用,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4