Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets Compiler Support MSBuild Toolset Version 16.0 #421

Merged
merged 9 commits into from Mar 28, 2019
19 changes: 11 additions & 8 deletions sources/assets/Xenko.Core.Assets/PackageSessionPublicHelper.cs
@@ -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"
};

Expand All @@ -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();
}
Expand Down Expand Up @@ -64,9 +63,13 @@ 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.Toolsets.Any(x => new Version(x.ToolsVersion).Major >= 15))
erictuvesson marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}
}

throw new InvalidOperationException("Could not find a supported MSBuild toolset version");
}
}
}