Problem
I just committed the addition of a UWP application to source control. However, my CI server (Jenkins) didn't seem to like that:
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.0\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
This is stemming from the following UWP project file import:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
On my local machine, I can see this file located at:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.Targets
Obviously, this is due to my local installation of Visual Studio 2017. However, the CI server does not have Visual Studio installed. I imagine this is why MSBuildExtensionsPath
is resolving to the path mentioned in the error instead.
Dependencies
The following items are already installed on the CI server:
- Visual Studio Build Tools 2017 (download)
- Windows 10 SDK 10.0.15063.468 (download)
- Xamarin.VisualStudio 4.5.0.476 (download)
- .NET Framework 4.5.1-4.7 SDKs
I assumed these would include the necessary dependencies, but I cannot find Microsoft.Windows.UI.Xaml.CSharp.targets
anywhere.
Workaround
Copying the directory on my local machine
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\WindowsXaml\v15.0
to the CI server at
C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.0
seems to resolve the error, but it feels very hacky.
Question
Is there a way to resolve this without installing Visual Studio 2017 on the CI server or copying/renaming files manually?
UPDATE 2018-01-12:
This is still an issue with the latest version of VSBT. The only thing to report is the error changed from v14 to v15. After copying the same directory over to v15, the error is gone again. However, another seemingly unrelated error shows up:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1124,5): error MSB3644: The reference assemblies for framework ".NETCore,Version=v5.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
UPDATE 2018-01-15
.NETCore,Version=v5.0
error resolved by copying the following directory from my local machine to the build server:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v5.0
While the UWP build is successful, no appxbundle is generated. This seems to indicate another dependency is missing from VSBT.