我是第一次尝试 WPF .NET Core,在新的 WPF .NET Framework 项目中我总是做的一件事就是打开控制台,但当我尝试在 .NET 中执行此操作时收到错误核。
在传统的 WPF 中,针对 .NET Framework,这相当简单;
我在 WPF .NET Core 中复制了这些步骤,但当我尝试更改 App.xaml 的构建操作时出现错误
错误(在“属性”窗口的下拉列表中选择“页面”后立即发生):
An error has occurred while saving the edited properties listed below:
Build Action
One or more values are invalid.
Cannot add 'App.xaml' to the project, because the path is explicitly excluded from the project
(C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.targets (45,5)).
Run Code Online (Sandbox Code Playgroud)
有谁知道解决这个问题的方法,或者在 WPF .NET Core 中启用控制台的其他方法?
设置以下属性将使您的 WPF 应用程序成为“控制台应用程序”
<PropertyGroup>
<OutputType>Exe</OutputType>
<DisableWinExeOutputInference>true</DisableWinExeOutputInference>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
对于 WPF 和 WinForms 应用程序,SDK 自动将 OutputType 从 更改Exe
为。WinExe
请参阅https://learn.microsoft.com/en-us/dotnet/core/compatibility/windows-forms/5.0/automatically-infer-winexe-output-type
归档时间: |
|
查看次数: |
3267 次 |
最近记录: |