0

I'm working on a WinUI3 application. I created the project using Template Studio and modified the project files to get is working with dotnet 9. Everything was going smooth until I needed to incorporate Sqlite using Ef Core.

When I run ef commands like dotnet ef migrations list or dotnet ef migrations add InitialMigration, I get the following error:

> dotnet ef migrations list
Build started...
Build failed. Use dotnet build to see the errors.

More specifically, if I run the commands with the verbose flag:

> dotnet ef migrations list --verbose
Using project 'C:\Users\tunde\source\repos\Adatu\Adatu.csproj'.
Using startup project 'C:\Users\tunde\source\repos\Adatu\Adatu.csproj'.
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\tunde\AppData\Local\Temp\tmpkqoghg.tmp /verbosity:quiet /nologo C:\Users\tunde\source\repos\Adatu\Adatu.csproj
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\tunde\AppData\Local\Temp\tmptifiqu.tmp /verbosity:quiet /nologo C:\Users\tunde\source\repos\Adatu\Adatu.csproj
Build started...
dotnet build C:\Users\tunde\source\repos\Adatu\Adatu.csproj /verbosity:quiet /nologo /p:PublishAot=false
C:\Users\tunde\.nuget\packages\microsoft.windowsappsdk\1.6.241114003\buildTransitive\Microsoft.WindowsAppSDK.SelfContained.targets(75,9): error : WindowsAppSDKSelfContained requires a supported Windows architecture. [C:\Users\tunde\source\repos\Adatu\Adatu.csproj]

Build FAILED.

C:\Users\tunde\.nuget\packages\microsoft.windowsappsdk\1.6.241114003\buildTransitive\Microsoft.WindowsAppSDK.SelfContained.targets(75,9): error : WindowsAppSDKSelfContained requires a supported Windows architecture. [C:\Users\tunde\source\repos\Adatu\Adatu.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:03.51

Workload updates are available. Run `dotnet workload list` for more information.

Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use dotnet build to see the errors.
   at Microsoft.EntityFrameworkCore.Tools.Project.Build(IEnumerable`1 additionalArgs)
   at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute(String[] _)
   at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args)
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Build failed. Use dotnet build to see the errors.

However, dotnet build does not fail. See the output below:

 dotnet build
Restore complete (1.0s)
  Adatu.Core succeeded (0.2s) → C:\Users\tunde\source\repos\Adatu.Core\bin\Debug\net9.0\Adatu.Core.dll
  Adatu succeeded (15.9s) → bin\x64\Debug\net9.0-windows10.0.22621.0\win-x64\Adatu.dll

Build succeeded in 17.6s

Workload updates are available. Run `dotnet workload list` for more information.

I have searched all over the internet but cannot find much information about the WindowsAppSDKSelfContained requires a supported Windows architecture. error. Apart from running migrations, everything else seems fine. I'll be glad if someone can look at my project files and maybe spot something I'm doing wrong.

The project files are below: // The startup project - Adatu.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net9.0-windows10.0.22621.0</TargetFramework>
    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
    <RootNamespace>Adatu</RootNamespace>
    <ApplicationIcon>Assets/WindowIcon.ico</ApplicationIcon>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <Platforms>x86;x64;arm64</Platforms>
    <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
    <PublishProfile>Properties\PublishProfiles\win-$(Platform).pubxml</PublishProfile>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <UseWinUI>true</UseWinUI>
    <EnableMsixTooling>true</EnableMsixTooling>
    <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

  <ItemGroup>
    <Manifest Include="$(ApplicationManifest)" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
    <PackageReference Include="CommunityToolkit.WinUI.Controls.HeaderedControls" Version="8.1.240916" />
    <PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.1.240916" />
    <PackageReference Include="CommunityToolkit.WinUI.Controls.RangeSelector" Version="8.1.240916" />
    <PackageReference Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.1.240916" />
    <PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240916" />
    <PackageReference Include="CommunityToolkit.WinUI.Controls.Sizers" Version="8.1.240916" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241114003" />
    <PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
    <PackageReference Include="WinUIEx" Version="2.5.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Adatu.Core\Adatu.Core.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="appsettings.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
    <ProjectCapability Include="Msix" />
  </ItemGroup>
  
  <PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
    <HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
  </PropertyGroup>
</Project>

...And the related project (which also has the DbContext) - Adatu.Core:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <RootNamespace>Adatu.Core</RootNamespace>
    <Platforms>x64;x86</Platforms>
    <Platforms>x86;x64;arm64;</Platforms>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
  </ItemGroup>
</Project>

Further information that might help:

dotnet ef --version
Entity Framework Core .NET Command-line Tools
9.0.0
dotnet --info
.NET SDK:
 Version:           9.0.101
 Commit:            eedb237549
 Workload version:  9.0.100-manifests.4a280210
 MSBuild version:   17.12.12+1cce77968

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.101\

.NET workloads installed:
 [maui-windows]
   Installation Source: VS 17.12.35527.113
   Manifest Version:    9.0.0/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.0\WorkloadManifest.json
   Install Type:              Msi

 [maccatalyst]
   Installation Source: VS 17.12.35527.113
   Manifest Version:    18.1.9163/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.1.9163\WorkloadManifest.json
   Install Type:              Msi
[ios]
   Installation Source: VS 17.12.35527.113
   Manifest Version:    18.1.9163/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.1.9163\WorkloadManifest.json
   Install Type:              Msi

 [aspire]
   Installation Source: VS 17.12.35527.113
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

 [android]
   Installation Source: VS 17.12.35527.113
   Manifest Version:    35.0.7/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.7\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

.NET SDKs installed:
  9.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Thank you in advance.

2 Answers 2

1

I finally found the problem and it had nothing to do with the windows architecture as the error was pointing at. It was actually an error with model inheritance in my code.

For anyone that might experience such in the future, I started by changing WindowsAppSDKSelfContained to false. After doing that, the errors from my models appeared. I fixed them and switched WindowsAppSDKSelfContained back to true and the commands still work as expected.

Sign up to request clarification or add additional context in comments.

Comments

0
  1. Add to project:

    1. <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="X.0.0.0">
      <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers;buildtransitive</IncludeAssets>
      </PackageReference>
      
  2. see:

Add-Migration fails on WinUI 3

New contributor
Андрей Кривошеев is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.