Let's say that the VisualStudio license terms don't fit my use case. Perhaps my employer defines itself as a "Java shop", and I'd like to show them the goodness of native apps. But I can't do so by producing an app they're not free to distribute.
So I'm trying to build a WinUI 3 app with the dotnet CLI. I've tried to reproduce the essence of the build file for the SimplePhotos tutorial app.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>MyOrg.MyApp</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x64;ARM64</Platforms>
<RuntimeIdentifiers>win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<WindowsPackageType>None</WindowsPackageType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230313.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
</Project>
And I've created an app.manifest
file:
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApp.app" />
<compatibility>
<application>
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
</application>
</compatibility>
<application>
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
</assembly>
For argument's sake, let's say I have minimal App.cs
and MainWindow.cs
files.
Now I try to build the app, and I see:
PS > dotnet build MyApp/MyApp.csproj
C:\Users\<my-user-id>\.nuget\packages\microsoft.windowsappsdk\1.2.230313.1
\buildTransitive\MrtCore.PriGen.targets(911,5): error MSB4062: The
"Microsoft.Build.Packaging.Pri.Tasks.ExpandPriContent" task could not be
loaded from the assembly C:\Program Files\dotnet\sdk\7.0.302\\Microsoft
\VisualStudio\v17.0\AppxPackage\\Microsoft.Build.Packaging.Pri.Tasks.dll.
Could not load file or assembly 'C:\Program Files\dotnet\sdk\7.0.302\Microsoft
\VisualStudio\v17.0\AppxPackage\Microsoft.Build.Packaging.Pri.Tasks.dll'.
The system cannot find the path specified. Confirm that the <UsingTask>
declaration is correct, that the assembly and all its dependencies are
available, and that the task contains a public class that implements
Microsoft.Build.Framework.ITask.
Build FAILED.
Is there any way to build this project without a VisualStudio installation?