[英]How can I change App.xaml build action from Application Definition to Page
I want make mutex, so I tried change App.xaml build action from AppDefinition To Page, then vs2019 said below:我想制作互斥锁,所以我尝试将 App.xaml 构建操作从 AppDefinition 更改为页面,然后 vs2019 如下所示:
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.1.100-preview8-013656\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.targets (57,5)).
I tried commented out, but then my app doesn't work.我尝试注释掉,但后来我的应用程序不起作用。
How can I change build action?如何更改构建操作?
If you target .NET Core you should implement your custom Main
method as usual and then edit the .csproj
file to include a <StartupObject>
element that specifies the type where your custom Main
method is defined instead of changing the build action of App.xaml
:如果以 .NET Core 为目标,则应照常实现自定义Main
方法,然后编辑.csproj
文件以包含<StartupObject>
元素,该元素指定定义自定义Main
方法的类型,而不是更改App.xaml
的构建操作:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>
<Version>1.0.5</Version>
<StartupObject>WpfCoreApp1.MyProgramClass</StartupObject>
</PropertyGroup>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.