簡體   English   中英

如何將 App.xaml 構建操作從應用程序定義更改為頁面

[英]How can I change App.xaml build action from Application Definition to Page

我想制作互斥鎖,所以我嘗試將 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)).

我嘗試注釋掉,但后來我的應用程序不起作用。

如何更改構建操作?

如果以 .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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM