WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

MergeWindowsAppSDKManifests target fails when username contains a space

Open stewienj opened this issue 3 years ago • 1 comments

Describe the bug

The MergeWindowsAppSDKManifests target at line 19 in .nuget\packages\microsoft.windowsappsdk\1.0.0\build\Microsoft.WindowsAppSDK.SelfContained.targets doesn't handle paths containing a space. The Exec command looks like this:

<Exec Command="&quot;$(ManifestTool)&quot; -nologo -manifest $(ApplicationManifest) @(Manifest, ' ') -out:Microsoft.WindowsAppSdk.manifest"/>

But should look like this:

<Exec Command="&quot;$(ManifestTool)&quot; -nologo -manifest $(ApplicationManifest) @(Manifest->'&quot;%(FullPath)&quot;', ' ') -out:Microsoft.WindowsAppSdk.manifest"/>

The result is when you compile an app that has the property WindowsAppSDKSelfContained set to true you get the following error:

1>Target MergeWindowsAppSDKManifests:
1>  Building target "MergeWindowsAppSDKManifests" completely.
1>  No input files were specified.
1>  Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>  Task "Exec"
1>    "C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86\mt.exe" -nologo -manifest app.manifest app.manifest C:\Users\Joe Bloggs\.nuget\packages\microsoft.windowsappsdk\1.0.0\manifests\Microsoft.InteractiveExperiences.manifest C:\Users\Joe Bloggs\.nuget\packages\microsoft.windowsappsdk\1.0.0\manifests\Microsoft.WindowsAppSdk.Foundation.manifest C:\Users\Joe Bloggs\.nuget\packages\microsoft.windowsappsdk\1.0.0\manifests\Microsoft.WindowsAppSdk.WinUI.manifest -out:Microsoft.WindowsAppSdk.manifest
1>
1>    C:\Users\Joe : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
1>
1>    C:\Users\Joe Bloggs\.nuget\packages\microsoft.windowsappsdk\1.0.0\build\Microsoft.WindowsAppSDK.SelfContained.targets(19,5): error MSB3073: The command ""C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86\mt.exe" -nologo -manifest app.manifest app.manifest C:\Users\Joe Bloggs\.nuget\packages\microsoft.windowsappsdk\1.0.0\manifests\Microsoft.InteractiveExperiences.manifest C:\Users\Joe Bloggs\.nuget\packages\microsoft.windowsappsdk\1.0.0\manifests\Microsoft.WindowsAppSdk.Foundation.manifest C:\Users\Joe Bloggs\.nuget\packages\microsoft.windowsappsdk\1.0.0\manifests\Microsoft.WindowsAppSdk.WinUI.manifest -out:Microsoft.WindowsAppSdk.manifest" exited with code 31.
1>  Done executing task "Exec" -- FAILED.
1>Done building target "MergeWindowsAppSDKManifests" in project "App1.csproj" -- FAILED.

A workaround for this error is to put the following at the bottom of your project file:

  <!-- There's a bug in .nuget\packages\microsoft.windowsappsdk\1.0.0\build\Microsoft.WindowsAppSDK.SelfContained.targets this fixes that -->
  
  <Target Name="MergeWindowsAppSDKManifestsBefore"
   Condition="'$(WindowsAppSDKFrameworkPackage)'=='false' and '$(MSBuildProjectExtension)' == '.csproj'"
   BeforeTargets="_SetEmbeddedWin32ManifestProperties;MergeWindowsAppSDKManifests"
   Outputs="Microsoft.WindowsAppSdk.manifest">
    <Exec Command="&quot;$(ManifestTool)&quot; -nologo -manifest $(ApplicationManifest) @(Manifest->'&quot;%(FullPath)&quot;', ' ') -out:Microsoft.WindowsAppSdk.manifest"/>
    <PropertyGroup>
      <ApplicationManifest>Microsoft.WindowsAppSdk.manifest</ApplicationManifest>
      <WindowsAppSDKFrameworkPackage>true</WindowsAppSDKFrameworkPackage>
    </PropertyGroup>
  </Target>

  <Target Name="MergeWindowsAppSDKManifestsAfter" AfterTargets="MergeWindowsAppSDKManifests">
    <PropertyGroup>
      <WindowsAppSDKFrameworkPackage>false</WindowsAppSDKFrameworkPackage>
    </PropertyGroup>
  </Target>

Steps to reproduce the bug

  • Log into a user profile that has a space in the profile name
  • In Visual Studio 2019 create a new project of type "Blank App, Packaged (WinUI 3 in Desktop)"
  • Remove the Package.appxmanifest file
  • Add the following properties to the top PropertyGroup element:
<WindowsPackageType>None</WindowsPackageType>
<SelfContained>true</SelfContained>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
  • Build the application
  • See the error message

Expected behavior

The application should compile

Screenshots

No response

NuGet package version

1.0.0

Packaging type

Unpackaged

Windows version

May 2021 Update (19043)

IDE

Visual Studio 2019

Additional context

No response

stewienj avatar Nov 19 '21 00:11 stewienj

@BenJKuhn tag

DrusTheAxe avatar Nov 19 '21 04:11 DrusTheAxe

Fixed in Windows App SDK 1.3.

A workaround that allows the user folder to retain the space:

mklink /d NUGET_PACKAGES %userprofile%.nuget\packages set NUGET_PACKAGES=c:\NUGET_PACKAGES

A persistent definition of the NUGET_PACKAGES env var will override the userprofile default.

Scottj1s avatar Nov 23 '22 00:11 Scottj1s