In my WinUI (3) test app, the .csproj begins like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net10.0-windows10.0.26100.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>WinUITests12</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">win-$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</RuntimeIdentifier>
<PublishProfile Condition="Exists('Properties\PublishProfiles\win-$(Platform).pubxml')">win-$(Platform).pubxml</PublishProfile>
<WinUIDSKReferences>false</WinUIDSKReferences>
<EnableMsixTooling>true</EnableMsixTooling>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWinUI>true</UseWinUI>
</PropertyGroup>
When I attempt to build, I get this error:
CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.
From my understanding, this error is occurring because WinUI apps define their own entry point and if GenerateProgramFiles is true, Microsoft.NET.Test.Sdk.Program.cs is auto-generated with its own entry point.
When I set GenerateProgramFiles to false within the project file, the app builds and runs as expected.
However, based on this line in Microsoft.NET.Test.Sdk.targets, I'm wondering if the UseWinUI property is meant to set GenerateProgramFiles to false when GenerateProgramFiles is not set in the project file. If so, it looks like the following line in the same file overrides the previous line and sets GenerateProgramFiles back to true. If UseWinUI is meant to set GenerateProgramFiles to false, I think both evaluations of true and false should include UseWinUI and UseUwpTools.
Am I misunderstanding the UseWinUI property and/or Microsoft.NET.Test.Sdk.targets? I appreciate any insight you can provide.
In my WinUI (3) test app, the .csproj begins like this:
When I attempt to build, I get this error:
CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.
From my understanding, this error is occurring because WinUI apps define their own entry point and if
GenerateProgramFilesis true, Microsoft.NET.Test.Sdk.Program.cs is auto-generated with its own entry point.When I set
GenerateProgramFilesto false within the project file, the app builds and runs as expected.However, based on this line in Microsoft.NET.Test.Sdk.targets, I'm wondering if the
UseWinUIproperty is meant to setGenerateProgramFilesto false whenGenerateProgramFilesis not set in the project file. If so, it looks like the following line in the same file overrides the previous line and setsGenerateProgramFilesback to true. IfUseWinUIis meant to setGenerateProgramFilesto false, I think both evaluations of true and false should includeUseWinUIandUseUwpTools.Am I misunderstanding the
UseWinUIproperty and/orMicrosoft.NET.Test.Sdk.targets? I appreciate any insight you can provide.