简体   繁体   中英

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:

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 :

<PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UseWPF>true</UseWPF>
    <Version>1.0.5</Version>
    <StartupObject>WpfCoreApp1.MyProgramClass</StartupObject>
</PropertyGroup>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM