I try to run an MSBuild command to package an UWP application from an azure TFS build step.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" "C:\TFSagent\_work\1\s\MyProject.sln" /t:Build /p:Configuration=master /p:Platform=x86"
This command execute well when i log onto the remote VM agent and i just execute the command: package is created just fine as expected.
But when the command is executed via TFS Agent that runs as a service i got the following error :
2019-06-16T22:15:16.0141845Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(2638,5): error APPX0002: Task 'ValidateAppxManifest' failed. Namespace prefix 'm' is not defined. [C:\TFSagent\_work\1\s\MyProject.vcxproj]
2019-06-16T22:15:16.0142853Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(2638,5): error APPX0002: [C:\TFSagent\_work\1\s\MyProject.vcxproj]
2019-06-16T22:15:16.9689847Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(2638,5): error MSB4018: The "ValidateAppxManifest" task failed unexpectedly. [C:\TFSagent\_work\1\s\MyProject.vcxproj]
2019-06-16T22:15:16.9690436Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(2638,5): error MSB4018: System.Xml.XPath.XPathException: Namespace prefix 'm' is not defined. [C:\TFSagent\_work\1\s\MyProject.vcxproj]
...
Running: Microsoft Visual Studio Team Foundation Server Version 16.131.28507.4
Agent is setup as a service, on a windows 10 vm, using a local user, that is granted administrator rights.
Build Step is as simple as a command-line executing te above command.
I've tried adding /nodeReuse:false /m:1
.
There is no use of any 'm' namespace in the corresponding manifest (and as it works when runnning 'by hand' i suppose the manifest itself is fine)
I just expect the command to work the same when running from a user or a service.
i may have found where the 'm' namespace comes from (when using /v:diag
:
Task Parameter:
AppxManifestSchemas=
C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\WinRT\FoundationManifestSchema.xsd
NamespaceAlias=m
NamespaceUri=http://schemas.microsoft.com/appx/manifest/foundation/windows10
C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\WinRT\UapManifestSchema.xsd
NamespaceAlias=uap
NamespaceUri=http://schemas.microsoft.com/appx/manifest/uap/windows10 (TaskId:271)
in the non working msbuild diag log, the parameter AppxManifestSchemas does not appear at all, probably explaining the intial error. next step : finding why the parameter is not send to the task.
Solution found! I had a Variable in my Build Definition named "SdkVersion" which was used to control the target sdk i wanted to build on. This variable was used in my command line only.
Thing is, TFS is creating an environment variable for each variable in the build configuration. During the MsBuild PRocess, and specifically task 'GetSdkPropertyValue' (task which is a dependecy for ValidateAppxManifest', which apparently add some AppxManifestSchema, including one with NamespaceAlias=m )
, there is a parameter named 'SDKVERSION' .. by default (when running manually) it takes the value '10.0' but as i had a variable with same name, it was overidde with '10.0.18362.0' which leads to adding no appxmanifestschema... Took me a month :p