我通过选择 .Net Framework 4.6
使用 VisualStudio 2017
创建了一个 WPF 应用程序。知道我正在尝试为 WPF 的 .Net Core 3.0 配置它。但不幸的是,在更改我的配置后,重新加载我的项目时,我收到了此错误。
Project file is incomplete. Expected imports are missing.
我已经检查了所有引用文件。
这是我的 .csproj
文件。
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>HelloWorld</AssemblyName>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Include="..\WpfApp\App.xaml" Link="App.xaml" />
<Compile Include="..\WpfApp\App.xaml.cs" Link="App.xaml.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="..\WpfApp\MainWindow.xaml" Link="MainWindow.xaml" />
<Compile Include="..\WpfApp\MainWindow.xaml.cs" Link="MainWindow.xaml.cs" />
</ItemGroup>
</Project>
我已经安装了此 SDK 版本 3.0.100-preview5-011568
。我还在 VisualStudio 中启用了使用 .Net Core SDK 预览。
最佳答案
您应该升级到 Visual Studio 2019。它包含面向 .NET Core 3 的 WPF 和 Windows 窗体应用程序的项目模板。
来自docs :
Visual Studio 2017 doesn't support .NET Core 3.0 projects.
关于c# - DotNetCore3.0 WPF - 错误 - 项目文件不完整。缺少预期进口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56492574/