microsoft / msix-packaging

MSIX SDK
MIT License
988 stars 166 forks source link

[BUG] Pipeline error says "Could not find a part of the path 'D:\a\1\s\*.MsixInstaller_x64.appinstaller' #456

Open Jharr20210609 opened 3 years ago

Jharr20210609 commented 3 years ago

Project https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects

Describe the bug

"D:\a\1\s\ProjectName1_Production.sln" (default target) (1) ->
"D:\a\1\s\ProjectName1.MsixInstaller\ProjectName1.MsixInstaller.wapproj" (default target) (5) ->
(GenerateAppInstallerFileForPackage target) -> 
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(6361,5): error : System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\a\1\s\ProjectName1.MsixInstaller\AppPackages\ProjectName1.MsixInstaller_x64.appinstaller'. [D:\a\1\s\ProjectName1.MsixInstaller\ProjectName1.MsixInstaller.wapproj]

    26 Warning(s)
    1 Error(s)

To Reproduce I followed the instructions per this website and I am getting the following error on the MSIX build and package task:

Expected behavior The task should complete successfully.

Screenshots image image

Platform Windows-2019

Additional context I am not sure why this is trying to find the appinstaller file during the MSIX build stage.

Full Pipeline YAML

pool: name: Azure Pipelines demands: msbuild


#Your build pipeline references an undefined variable named ‘BuildConfiguration’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

steps:
- task: NuGetToolInstaller@1
  displayName: 'Use NuGet'
  inputs:
    versionSpec: 5.9.1
    checkLatest: true

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: 'ProjectName1_Production.sln'

- task: MSIX.msix-ci-automation-task.msix-packaging.MsixPackaging@1
  displayName: 'MSIX build and package'
  inputs:
    outputPath: '$(Build.ArtifactStagingDirectory)\ProjectName1.msix'
    solution: 'ProjectName1_Production.sln'
    buildPlatform: x64
    updateAppVersion: true
    manifestFile: ProjectName1.MsixInstaller/Package.appxmanifest
    appPackageDistributionMode: SideloadOnly
    msbuildArchitecture: x64

- task: MSIX.msix-ci-automation-task.msix-signing.MsixSigning@1
  displayName: 'Sign MSIX package'
  inputs:
    certificate: 'DeveloperCodeSigningCert_TemporaryKey.pfx'
    passwordVariable: signingCert.password

- task: MSIX.msix-ci-automation-task.app-installer-file.AppInstallerFile@1
  displayName: 'Create App Installer file'
  inputs:
    package: '$(Build.ArtifactStagingDirectory)\ProjectName1.msix'
    outputPath: '$(Build.ArtifactStagingDirectory)\ProjectName1.appinstaller'
    uri: 'https://ProjectName1demo.azurewebsites.net/ProjectName1.appinstaller'
    mainItemUri: 'https://ProjectName1demo.azurewebsites.net/ProjectName1.msix'
    showPromptWhenUpdating: true
    updateBlocksActivation: true

- task: MSIX.msix-ci-automation-task.msix-app-attach.MsixAppAttach@1
  displayName: 'Create package for MSIX app attach'
  inputs:
    package: '$(Build.ArtifactStagingDirectory)\ProjectName1.msix'
    vhdxOutputPath: '$(Build.ArtifactStagingDirectory)\ProjectName1.vhdx'
    vhdxSize: 200

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    Contents: '**\bin\**\$(BuildConfiguration)\**'
    TargetFolder: '$(build.artifactstagingdirectory)'
    CleanTargetFolder: true
    OverWrite: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
Jharr20210609 commented 3 years ago

Accidentally closed trying to add a header/topic line. This issue still exists.

florelis commented 3 years ago

I'm not sure why it fails but I have a couple of suggestions to try and narrow it down.

It seems your project is set up to create the .appinstaller file during build. Could you share the contents of your .wapproj project file?

The MSIX build task calls msbuild.exe with some special parameters for building the package. You should be able to see the full command in the task logs. Does it build correctly if you run the same command locally? Does it succeed if you use the MSBuild or VSBuild tasks with those arguments?

Jharr20210609 commented 3 years ago

The MSBuild Clean Command is:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\msbuild.exe" "C:\some\project\or\other\src\ProjectName1.sln" /p:Platform=x64 /p:Configuration=debug /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxPackageSigningEnabled=false /p:AppxBundle=Never /p:AppxPackageOutput=C:\temp\ProjectName1.msix /t:Clean

The MSBuild Build Command is:

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\msbuild.exe" "C:\some\project\or\other\src\ProjectName1.sln" /p:Platform=x64 /p:Configuration=debug /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxPackageSigningEnabled=false /p:AppxBundle=Never /p:AppxPackageOutput=C:\temp\ProjectName1.msix

When I run the commands above in PowerShell (In Admin mode), the MSIX is successfully created and I am able to use MSIXManager to convert the MSIX into a VHDX.

I can build the projects in Visual Studio and I get the MSIX file when I use the Publish feature on the MsixInstaller project. I have never used VSBuild through PowerShell, so I do not know what that command would be.

The contents of the .wapproj file are as follows: Note: I have replaced the actual thumbprint with AThumbPrint

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
    <VisualStudioVersion>15.0</VisualStudioVersion>
  </PropertyGroup>
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Demo|x64">
      <Configuration>Demo</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Development|x64">
      <Configuration>Development</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Production|x64">
      <Configuration>Production</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup>
    <WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
  </PropertyGroup>
  <Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
  <PropertyGroup>
    <ProjectGuid>6252bba9-ef8e-4b89-96b2-d02271c8652e</ProjectGuid>
    <TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
    <DefaultLanguage>en-US</DefaultLanguage>
    <AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
    <PackageCertificateThumbprint>_AThumbPrint_</PackageCertificateThumbprint>
    <GenerateAppInstallerFile>True</GenerateAppInstallerFile>
    <AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
    <AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
    <AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
    <GenerateTestArtifacts>True</GenerateTestArtifacts>
    <AppxBundlePlatforms>x64</AppxBundlePlatforms>
    <AppInstallerUri>https://ProjectName1demo.azurewebsites.net</AppInstallerUri>
    <HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
    <EntryPointProjectUniqueName>..\ProjectName1\ProjectName1.csproj</EntryPointProjectUniqueName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Demo|x64'">
    <AppxBundle>Never</AppxBundle>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Production|x64'">
    <AppxBundle>Never</AppxBundle>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <AppxBundle>Never</AppxBundle>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Development|x64'">
    <AppxBundle>Never</AppxBundle>
  </PropertyGroup>
  <ItemGroup>
    <AppxManifest Include="Package.appxmanifest">
      <SubType>Designer</SubType>
    </AppxManifest>
  </ItemGroup>
  <Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
  <ItemGroup>
    <Content Include="Package.appinstaller" />
    <Content Include="Images\BadgeLogo.scale-100.png" />
    <Content Include="Images\BadgeLogo.scale-125.png" />
    <Content Include="Images\BadgeLogo.scale-150.png" />
    <Content Include="Images\BadgeLogo.scale-200.png" />
    <Content Include="Images\BadgeLogo.scale-400.png" />
    <Content Include="Images\LargeTile.scale-100.png" />
    <Content Include="Images\LargeTile.scale-125.png" />
    <Content Include="Images\LargeTile.scale-150.png" />
    <Content Include="Images\LargeTile.scale-200.png" />
    <Content Include="Images\LargeTile.scale-400.png" />
    <Content Include="Images\SmallTile.scale-100.png" />
    <Content Include="Images\SmallTile.scale-125.png" />
    <Content Include="Images\SmallTile.scale-150.png" />
    <Content Include="Images\SmallTile.scale-200.png" />
    <Content Include="Images\SmallTile.scale-400.png" />
    <Content Include="Images\SplashScreen.scale-100.png" />
    <Content Include="Images\SplashScreen.scale-125.png" />
    <Content Include="Images\SplashScreen.scale-150.png" />
    <Content Include="Images\SplashScreen.scale-200.png" />
    <Content Include="Images\SplashScreen.scale-400.png" />
    <Content Include="Images\Square150x150Logo.scale-100.png" />
    <Content Include="Images\Square150x150Logo.scale-125.png" />
    <Content Include="Images\Square150x150Logo.scale-150.png" />
    <Content Include="Images\Square150x150Logo.scale-200.png" />
    <Content Include="Images\Square150x150Logo.scale-400.png" />
    <Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-16.png" />
    <Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-24.png" />
    <Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-256.png" />
    <Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-32.png" />
    <Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-48.png" />
    <Content Include="Images\Square44x44Logo.altform-unplated_targetsize-16.png" />
    <Content Include="Images\Square44x44Logo.altform-unplated_targetsize-24.png" />
    <Content Include="Images\Square44x44Logo.altform-unplated_targetsize-256.png" />
    <Content Include="Images\Square44x44Logo.altform-unplated_targetsize-32.png" />
    <Content Include="Images\Square44x44Logo.altform-unplated_targetsize-48.png" />
    <Content Include="Images\Square44x44Logo.scale-100.png" />
    <Content Include="Images\Square44x44Logo.scale-125.png" />
    <Content Include="Images\Square44x44Logo.scale-150.png" />
    <Content Include="Images\Square44x44Logo.scale-200.png" />
    <Content Include="Images\Square44x44Logo.scale-400.png" />
    <Content Include="Images\Square44x44Logo.targetsize-16.png" />
    <Content Include="Images\Square44x44Logo.targetsize-24.png" />
    <Content Include="Images\Square44x44Logo.targetsize-256.png" />
    <Content Include="Images\Square44x44Logo.targetsize-32.png" />
    <Content Include="Images\Square44x44Logo.targetsize-48.png" />
    <Content Include="Images\StoreLogo.scale-100.png" />
    <Content Include="Images\StoreLogo.scale-125.png" />
    <Content Include="Images\StoreLogo.scale-150.png" />
    <Content Include="Images\StoreLogo.scale-200.png" />
    <Content Include="Images\StoreLogo.scale-400.png" />
    <Content Include="Images\Wide310x150Logo.scale-100.png" />
    <Content Include="Images\Wide310x150Logo.scale-125.png" />
    <Content Include="Images\Wide310x150Logo.scale-150.png" />
    <Content Include="Images\Wide310x150Logo.scale-200.png" />
    <Content Include="Images\Wide310x150Logo.scale-400.png" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\ProjectName1\ProjectName1.csproj">
      <SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
    </ProjectReference>
  </ItemGroup>
</Project>
Jharr20210609 commented 3 years ago

After additional testing, I think I know what may be causing the error.

Is this the cause of the bug in the task? Does the task account for the fact that the file names change based on whether or not the user wants the bundle? Note: when the Bundle is select, the text _x64 is appended to the file name.

So, I think the task should check whether or not the MSIX bundle feature is checked and use that to determine the output name for the .appinstaller file.

Jharr20210609 commented 3 years ago

As a potential hack to fix this bug, I changed the name of the project file to ProjectName1.MsixInstaller_x64.wapproj, and of course the task just appended _x64 to the file name to give the following error:

Could not find a part of the path 'D:\a\1\s\ProjectName1.MsixInstaller\AppPackages\ProjectName1.MsixInstaller_x64_x64.appinstaller

Priceless.

florelis commented 3 years ago

Your project file specifies that the generated package should be signed and that an .appinstaller file should be generated:

    <AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
    ...
    <GenerateAppInstallerFile>True</GenerateAppInstallerFile>

That will be done by MSBuild when you build the package with the MSIXPackaging task. You probably do not need to have it done by both MSBuild and the signing/.appinstaller tasks, so you could remove one of the two. If creating the App Installer file when building is causing issues, you could try changing GenerateAppInstallerFile to False and generate it with the AppInstallerFile pipeline task.

Although I'd still want to figure out why it is failing in the first place and make that not happen.

Jharr20210609 commented 3 years ago

That worked. This still seems like a potential bug. Do you want me to leave this open?

florelis commented 3 years ago

That's good to hear.

Yes, it does sound like a bug, so let's keep this open until it is fixed.