I have a project using .net core 3.1 with Windows Forms and a Windows Application Packaging project in the same solution. I had this pipeline working for the past couple of months and now it seems to have stopped working. I'm not sure, but it seems to be failing to find a .target file from within the hosted agent I'm using to run the pipeline.
I tried using the VS Msbuild step and the MSBuild standalone one, also tried specific NuGet versions(5.2.0,5.8.0,5.10.0) with Nuget Restore step. But nothing seems to help.
Does anyone have some clue where to start looking?
The error:
...
CopyFilesToOutputDirectory:
Copying file from "D:\a\1\s\PrinterAgent\PrinterAgent\obj\Release\netcoreapp3.1\PrinterAgent.dll" to "D:\a\1\s\PrinterAgent\PrinterAgent\bin\Release\netcoreapp3.1\PrinterAgent.dll".
PrinterAgent -> D:\a\1\s\PrinterAgent\PrinterAgent\bin\Release\netcoreapp3.1\PrinterAgent.dll
Copying file from "D:\a\1\s\PrinterAgent\PrinterAgent\obj\Release\netcoreapp3.1\PrinterAgent.pdb" to "D:\a\1\s\PrinterAgent\PrinterAgent\bin\Release\netcoreapp3.1\PrinterAgent.pdb".
Done Building Project "D:\a\1\s\PrinterAgent\PrinterAgent\PrinterAgent.csproj" (default targets).
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\DesktopBridge\Microsoft.DesktopBridge.targets(16,3): Error MSB4019: The imported project "C:\hostedtoolcache\windows\dotnet\sdk\3.1.411\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.NuGet.targets" was not found. Confirm that the expression in the Import declaration "C:\hostedtoolcache\windows\dotnet\sdk\3.1.411\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.NuGet.targets" is correct, and that the file exists on disk.
Project "D:\a\1\s\PrinterAgent\PrinterAgent.sln" (1) is building "D:\a\1\s\PrinterAgent\PrinterAgent.Package\PrinterAgent.Package.wapproj" (3) on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\DesktopBridge\Microsoft.DesktopBridge.targets(16,3): error MSB4019: The imported project "C:\hostedtoolcache\windows\dotnet\sdk\3.1.411\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.NuGet.targets" was not found. Confirm that the expression in the Import declaration "C:\hostedtoolcache\windows\dotnet\sdk\3.1.411\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.NuGet.targets" is correct, and that the file exists on disk. [D:\a\1\s\PrinterAgent\PrinterAgent.Package\PrinterAgent.Package.wapproj]
Done Building Project "D:\a\1\s\PrinterAgent\PrinterAgent.Package\PrinterAgent.Package.wapproj" (default targets) -- FAILED.
Done Building Project "D:\a\1\s\PrinterAgent\PrinterAgent.sln" (default targets) -- FAILED.
Build FAILED.
"D:\a\1\s\PrinterAgent\PrinterAgent.sln" (default target) (1) ->
"D:\a\1\s\PrinterAgent\PrinterAgent.Package\PrinterAgent.Package.wapproj" (default target) (3) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\DesktopBridge\Microsoft.DesktopBridge.targets(16,3): error MSB4019: The imported project "C:\hostedtoolcache\windows\dotnet\sdk\3.1.411\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.NuGet.targets" was not found. Confirm that the expression in the Import declaration "C:\hostedtoolcache\windows\dotnet\sdk\3.1.411\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.NuGet.targets" is correct, and that the file exists on disk. [D:\a\1\s\PrinterAgent\PrinterAgent.Package\PrinterAgent.Package.wapproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:07.08
##[error]Process 'msbuild.exe' exited with code '1'.
Pipeline Definition: Using windows-2019 agent
pool:
name: Azure Pipelines
demands:
- msbuild
- azureps
#Your build pipeline references the ‘packageName’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘packageName’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘BuildPlatform’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘msixInstallUrl’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references an undefined variable named ‘signingCert.password’. 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
#Your build pipeline references an undefined variable named ‘mySecureFile.secureFilePath’. 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
variables:
packageVersion: '1.0.0'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.1.411'
inputs:
version: 3.1.411
- powershell: |
[xml]$manifest= get-content ".\PrinterAgent\PrinterAgent.Package\Package.appxmanifest"
$manifest.Package.Identity.Version = "$(packageVersion).$(Build.BuildId)"
$manifest.Package.Identity.Name = "demo-864d9095-955f-4d3c-adb0-6574a5acb88b"
$manifest.Package.Properties.DisplayName = "$(packageName)"
$manifest.Package.Applications.Application.VisualElements.DisplayName = "$(packageName)"
$manifest.save(".\PrinterAgent\PrinterAgent.Package\Package.appxmanifest")
displayName: 'PowerShell Script'
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/*.csproj'
- task: DownloadSecureFile@1
displayName: 'Download secure file'
inputs:
secureFile: <fileId>
#Fails here
- task: MSBuild@1
displayName: 'Build solution **/*.sln'
inputs:
msbuildVersion: 16.0
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArguments: '/p:AppInstallerUri=$(msixInstallUrl) /p:AppxPackageDir="$(Build.ArtifactStagingDirectory)" /p:UapAppxPackageBuildMode=SideLoadOnly /p:GenerateAppInstallerFile=true /p:PackageCertificatePassword="$(signingCert.password)" /p:PackageCertificateKeyFile="$(mySecureFile.secureFilePath)" /p:AppInstallerCheckForUpdateFrequency=OnApplicationRun /p:AppInstallerUpdateFrequency=1 /p:AppInstallerShowPrompt=true'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
- task: AzureCLI@2
displayName: 'Azure CLI CleanUp blob'
inputs:
azureSubscription: <azureSubscription>
scriptType: ps
scriptLocation: inlineScript
inlineScript: 'az storage blob delete-batch --account-name <storage> --source ''$web'''
- task: AzureFileCopy@4
displayName: 'AzureBlob File Copy'
inputs:
SourcePath: '$(build.artifactstagingdirectory)/*'
azureSubscription: <azureSubscription>
Destination: AzureBlob
storage: <storageName>
ContainerName: '$web'