Skip to content
Permalink
Browse files

Assets Compiler Support MSBuild Toolset Version 16.0 (#421) (fixes #420)

* Support MSBuild Toolset Version 16.0
* Switch to Microsoft.Build.Locator 1.1.2
* Use new "Current" ToolsVersion (microsoft/msbuild#3778) -- this code will work with all newer versions of Visual Studio
  • Loading branch information
erictuvesson authored and xen2 committed Mar 28, 2019
1 parent 93c111a commit 60b21cd6d3fe0047b580b54655d186e8e3a42e09
@@ -1,23 +1,22 @@
// Copyright (c) Xenko contributors (https://xenko.com) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using Microsoft.Build.Locator;
using Xenko.Core.VisualStudio;

namespace Xenko.Core.Assets
{
/// <summary>
/// Helper class to load/save a VisualStudio solution.
/// </summary>
public class PackageSessionPublicHelper
public static class PackageSessionPublicHelper
{
private static readonly string[] s_msBuildAssemblies =
{
"Microsoft.Build", "Microsoft.Build.Framework", "Microsoft.Build.Tasks.Core",
"Microsoft.Build",
"Microsoft.Build.Framework",
"Microsoft.Build.Tasks.Core",
"Microsoft.Build.Utilities.Core"
};

@@ -33,7 +32,7 @@ public static void FindAndSetMSBuildVersion()
if (MSBuildInstance == null && Interlocked.Increment(ref MSBuildLocatorCount) == 1)
{
// Make sure it is not already loaded (otherwise MSBuildLocator.RegisterDefaults() throws an exception)
if (AppDomain.CurrentDomain.GetAssemblies().Where(IsMSBuildAssembly).Any())
if (AppDomain.CurrentDomain.GetAssemblies().Any(IsMSBuildAssembly))
{
MSBuildInstance = MSBuildLocator.QueryVisualStudioInstances().FirstOrDefault();
}
@@ -64,8 +63,11 @@ private static void CheckMSBuildToolset()
// Check that we can create a project
using (var projectCollection = new Microsoft.Build.Evaluation.ProjectCollection())
{
if (projectCollection.GetToolset("15.0") == null)
throw new InvalidOperationException("Could not find MSBuild toolset 15.0");
if (projectCollection.GetToolset("15.0") == null // VS 2017
&& projectCollection.GetToolset("Current") == null) // VS 2019+ (https://github.com/Microsoft/msbuild/issues/3778)
{
throw new InvalidOperationException("Could not find a supported MSBuild toolset version (expected 15.0 or later)");
}
}
}
}
@@ -15,7 +15,7 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.ServiceModel" />
<PackageReference Include="Microsoft.Build" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.0.18" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.1.2" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.7.0" />
<Reference Include="System.Windows.Forms" />
@@ -27,7 +27,7 @@
<HintPath>..\..\..\deps\libgit2\LibGit2Sharp.dll</HintPath>
</Reference>
<PackageReference Include="Microsoft.Build" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.0.18" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.1.2" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="1.16.30">
<EmbedInteropTypes>True</EmbedInteropTypes>

0 comments on commit 60b21cd

Please sign in to comment.
You can’t perform that action at this time.