0
votes

I have configured a UWP CI on inhouse hosted AzureDevOps 2019 server and it fails with following errors. I have followed this as a guide. Can someone guide me on this towards success?

YAML is as follows after the configuration:

resources: - repo: self queue: name: Default demands: - msbuild - visualstudio

Your build pipeline references an undefined variable named ‘Parameters.solution’. 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 ‘Parameters.secureFile’. 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 ‘buildPlatform’. 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 ‘cert.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 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 variables: appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\' steps: - task: NuGetToolInstaller@0 displayName: 'Use NuGet 4.4.1' inputs: versionSpec: 4.4.1

  • task: NuGetCommand@2 displayName: 'NuGet restore ***.sln' inputs: restoreSolution: '$(Parameters.solution)'

  • task: DownloadSecureFile@1 displayName: 'Download secure file' inputs: secureFile: '$(Parameters.secureFile)'

  • task: VSBuild@1 displayName: 'Build solution Main/BoardPACWinApp.sln' inputs: solution: Main/BoardPACWinApp.sln vsVersion: 16.0

msbuildArgs: '/p:AppxBundlePlatforms="$(buildPlatform)" /p:AppxPackageDir="$(appxPackageDir)" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="" /p:PackageCertificateKeyFile="$(cert.secureFilePath)"' platform: x64 configuration: '$(BuildConfiguration)' clean: true msbuildArchitecture: x64

  • task: PublishBuildArtifacts@1 displayName: 'Publish artifact: drop' inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)\AppxPackages' enabled: false

  • task: AppCenterDistribute@0 displayName: 'Deploy to Visual Studio App Center' inputs: symbolsIncludeParentDirectory: false enabled: false


For this setup, I used VS 2019 16.3 build tools with a test certificate (BoardPACWinApp_TemporaryKey.pfx) with no password. Please note I have installed VS 2019 on the build server (Windows Server 2019 (OS Build 17763.437)) just to make sure the build is a success and it does. But when I try the same thing on DevOps build agent it throws errors.

MSBuild Args:

[command]"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64\msbuild.exe" "C:\agent_work\4\s\Main\BoardPACWinApp.sln" /nologo /nr:false /dl:CentralLogger,"C:\agent_work_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.146.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=1f510b32-fa94-449c-ba47-94b46a5869d0|SolutionDir=C:\agent_work\4\s\Main"*ForwardingLogger,"C:\agent_work_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.146.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:AppxBundlePlatforms="x64" /p:AppxPackageDir="C:\agent_work\4\a\AppxPackages\" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="" /p:PackageCertificateKeyFile="C:\agent_work_temp\BoardPACWinApp_TemporaryKey.pfx" /p:platform="x64" /p:configuration="release" /p:VisualStudioVersion="16.0" /p:_MSDeployUserAgent="TFS_22ec7900-72ed-4ebd-b5a6-d4ba51a210dd_build_16_0"

Error:

[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(1300,5): Error MSB3816: Loading assembly "C:\Windows\ServiceProfiles\NetworkService.nuget\packages\runtime.win7.system.private.uri\4.3.0\runtimes\aot\lib\netcore50\System.Private.Uri.dll" failed. System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

[error]C:\Windows\ServiceProfiles\NetworkService.nuget\packages\runtime.win7.system.private.uri\4.3.0\runtimes\aot\lib\netcore50\System.Private.Uri.dll(0,0): Error MSB3103: Invalid Resx file. String reference not set to an instance of a String. Parameter name: suffix

csproj of my app:

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{F48A0CA8-2DA5-472A-B973-602F1645B32C}</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>com.IronOne.BoardPACWinApp</RootNamespace>
<AssemblyName>BoardPACWinApp</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>BoardPACWinApp_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>9B26FCF3AA71B71D3A1FE446F7002DB921BA5B68</PackageCertificateThumbprint>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<AppxPackageDir>C:\temp\</AppxPackageDir>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<AppxBundle>Always</AppxBundle>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppInstallerUpdateFrequency>0</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>

If you want me to tweek my CI setup let me know I'll do and post the errors I'm getting. Thank you.

1
Have you build this project on the Server directly without Azure devops? So that we could narrow the scope of this issue. And according to the error log, I see it reference the package runtime.win7.system.private.uri, is your project created with VS2015?Leo Liu-MSFT
Yes I have installed vs2019 on the server and did build manually and it works. Also the product stated in vs2015 and then migrated to 2019 after several years.SurenSaluka
Thanks for your quickly reply. Have you check if the package runtime.win7.system.private.uri exists on that server? If not, please try to add the MSBuild argument /p:VisualStudioVersion=16.0 to the MSBuild Args in the VS build task, then check the build result.Leo Liu-MSFT
Yes, I also noticed that. But I am surprised that what settings/options will cause vs to search for NetworkService.nuget` paths instead of NetworkService\.nuget`, did not make any progress, sorry.Leo Liu-MSFT
sorry for the later reply. I was involved in another thread. I will check it ASAP. BTW, if you create a new UWP project with VS2019, if you still have this issue?Leo Liu-MSFT

1 Answers

0
votes

I found the solution. I have kept my original project aside and added a new UWP project to a sample git repo and tried to build the solution and got the following error.

2019-10-01T12:31:51.4254403Z ##[error]C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\1.7.6\tools\Microsoft.NetNative.targets(535,5): Error MSB4018: The "ComputeManagedBinaries" task failed unexpectedly. System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd' is denied.

So I have checked the access of the "C:\Program Files (x86)\Windows Kits\10\UnionMetadata" folder and found

enter image description here

I have added "Everyone" full access and that error went away. I know "Everyone" is not the correct account that I should give permission to but at the moment I don't know the exact account permission missing here. (I hope someone will fill the gap here)

Then I got the following errors

[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(3545,5): Error MSB3021: Unable to copy file "C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0.\AppX\Retail\x86\Microsoft.VCLibs.x86.14.00.appx" to "C:\agent_work\8\a\AppxPackages\App1_3.51.12.0_Test\Dependencies\x86\Microsoft.VCLibs.x86.14.00.appx". Access to the path 'C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0.\AppX\Retail\x86\Microsoft.VCLibs.x86.14.00.appx' is denied.

2019-10-01T13:10:12.9935017Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(3545,5): Error MSB3021: Unable to copy file "C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0.\AppX\Retail\x64\Microsoft.VCLibs.x64.14.00.appx" to "C:\agent_work\8\a\AppxPackages\App1_3.51.12.0_Test\Dependencies\x64\Microsoft.VCLibs.x64.14.00.appx". Access to the path 'C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0.\AppX\Retail\x64\Microsoft.VCLibs.x64.14.00.appx' is denied.

2019-10-01T13:10:13.0014122Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(3545,5): Error MSB3021: Unable to copy file "C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0.\AppX\Retail\ARM\Microsoft.VCLibs.ARM.14.00.appx" to "C:\agent_work\8\a\AppxPackages\App1_3.51.12.0_Test\Dependencies\ARM\Microsoft.VCLibs.ARM.14.00.appx". Access to the path 'C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0.\AppX\Retail\ARM\Microsoft.VCLibs.ARM.14.00.appx' is denied.

2019-10-01T13:10:13.0015622Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(3545,5): Error MSB3021: Unable to copy file "C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0.\AppX\Retail\ARM64\Microsoft.VCLibs.ARM64.14.00.appx" to "C:\agent_work\8\a\AppxPackages\App1_3.51.12.0_Test\Dependencies\ARM64\Microsoft.VCLibs.ARM64.14.00.appx". Access to the path 'C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0.\AppX\Retail\ARM64\Microsoft.VCLibs.ARM64.14.00.appx' is denied.

I went to each folder and given the "Everyone" permission and all errors went away.

The problem it seems that I installed the UWP SDKs after setting up the DevOps server. So whatever the folder permissions required to the DevOps agents did not apply to the newly created folders. So the DevOps agent couldn't access it and it throws errors.

Hope this helps someone. Cheers!