Navigation Menu

Skip to content

Commit

Permalink
[Build] Require VS2019 instead of VS2017 to take advantage of new NuG…
Browse files Browse the repository at this point in the history
…et buildTransitive feature
  • Loading branch information
xen2 committed May 4, 2019
1 parent d552c97 commit 105bd5c
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 85 deletions.
2 changes: 1 addition & 1 deletion deps/Xenko.GitVersioning/Xenko.GitVersioning.csproj
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net472</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="LibGit2Sharp" Version="0.25.3" />
</ItemGroup>
</Project>
Expand Up @@ -13,8 +13,8 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Microsoft.Build" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
Expand Down
4 changes: 2 additions & 2 deletions sources/assets/Xenko.Core.Assets/PackageSession.cs
Expand Up @@ -404,10 +404,10 @@ public sealed partial class PackageSession : IDisposable, IAssetFinder
/// <summary>
/// The visual studio version property used for newly created project solution files
/// </summary>
public static readonly Version DefaultVisualStudioVersion = new Version("14.0.23107.0");
public static readonly Version DefaultVisualStudioVersion = new Version("16.0.0.0");

internal static readonly string SolutionHeader = @"Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
# Visual Studio 16
VisualStudioVersion = {0}
MinimumVisualStudioVersion = {0}".ToFormat(DefaultVisualStudioVersion);

Expand Down
17 changes: 7 additions & 10 deletions sources/assets/Xenko.Core.Assets/PackageSessionPublicHelper.cs
Expand Up @@ -31,19 +31,17 @@ public static void FindAndSetMSBuildVersion()
// Note: this should be called only once
if (MSBuildInstance == null && Interlocked.Increment(ref MSBuildLocatorCount) == 1)
{
MSBuildInstance = MSBuildLocator.QueryVisualStudioInstances().FirstOrDefault(x => x.Version.Major >= 16);

// Make sure it is not already loaded (otherwise MSBuildLocator.RegisterDefaults() throws an exception)
if (AppDomain.CurrentDomain.GetAssemblies().Any(IsMSBuildAssembly))
{
MSBuildInstance = MSBuildLocator.QueryVisualStudioInstances().FirstOrDefault();
}
else
if (MSBuildInstance != null && !AppDomain.CurrentDomain.GetAssemblies().Any(IsMSBuildAssembly))
{
MSBuildInstance = MSBuildLocator.RegisterDefaults();
MSBuildLocator.RegisterInstance(MSBuildInstance);
}
}

if (MSBuildInstance == null)
throw new InvalidOperationException("Could not find MSBuild Instance");
throw new InvalidOperationException("Could not find a MSBuild installation (expected 16.0 or later)");

CheckMSBuildToolset();
}
Expand All @@ -63,10 +61,9 @@ 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 // VS 2017
&& projectCollection.GetToolset("Current") == null) // VS 2019+ (https://github.com/Microsoft/msbuild/issues/3778)
if (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)");
throw new InvalidOperationException("Could not find a supported MSBuild toolset version (expected 16.0 or later)");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions sources/assets/Xenko.Core.Assets/Xenko.Core.Assets.csproj
Expand Up @@ -14,9 +14,9 @@
<ItemGroup>
<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.1.2" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.2" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.7.0" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WindowsBase" />
Expand Down
Expand Up @@ -85,7 +85,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ILRepack" Version="2.0.15"/>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
</ItemGroup>
<PropertyGroup>
Expand Down
37 changes: 12 additions & 25 deletions sources/core/Xenko.Core.Design/VisualStudio/VisualStudioVersions.cs
Expand Up @@ -13,13 +13,13 @@ namespace Xenko.Core.VisualStudio
{
public class IDEInfo
{
public IDEInfo(string version, string displayName, string installationPath, bool complete = true)
public IDEInfo(Version version, string displayName, string installationPath, bool complete = true)
{
if (version == null) throw new ArgumentNullException(nameof(version));

Complete = complete;
DisplayName = displayName ?? throw new ArgumentNullException(nameof(displayName));
Version = new Version(version);
Version = version;
InstallationPath = installationPath ?? throw new ArgumentNullException(nameof(installationPath));
}

Expand Down Expand Up @@ -79,8 +79,7 @@ public IDEInfo(string version, string displayName, string installationPath, bool
public enum VSIXInstallerVersion
{
None,
VS2015,
VS2017AndFutureVersions,
VS2019AndFutureVersions,
}

public static class VisualStudioVersions
Expand All @@ -89,7 +88,7 @@ public static class VisualStudioVersions
private const int REGDB_E_CLASSNOTREG = unchecked((int)0x80040154);
private static Lazy<List<IDEInfo>> IDEInfos = new Lazy<List<IDEInfo>>(BuildIDEInfos);

public static IDEInfo DefaultIDE = new IDEInfo("0.0", "Default IDE", string.Empty);
public static IDEInfo DefaultIDE = new IDEInfo(new Version("0.0"), "Default IDE", string.Empty);

public static IEnumerable<IDEInfo> AvailableVisualStudioInstances => IDEInfos.Value.Where(x => x.HasDevenv);

Expand All @@ -104,23 +103,6 @@ private static List<IDEInfo> BuildIDEInfos()
{
var ideInfos = new List<IDEInfo>();

// Visual Studio 14.0 (2015)
var localMachine32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
using (var subkey = localMachine32.OpenSubKey($@"SOFTWARE\Microsoft\{"VisualStudio"}\{"14.0"}"))
{
var path = (string)subkey?.GetValue("InstallDir");

var vs14InstallPath = (path != null) ? Path.Combine(path, "devenv.exe") : null;
if (vs14InstallPath != null && File.Exists(vs14InstallPath))
{
var vsixInstallerPath = Path.Combine(path, "VSIXInstaller.exe");
if (!File.Exists(vsixInstallerPath))
vsixInstallerPath = null;

ideInfos.Add(new IDEInfo("14.0", "Visual Studio 2015", path) { DevenvPath = vs14InstallPath, VsixInstallerVersion = VSIXInstallerVersion.VS2015, VsixInstallerPath = vsixInstallerPath });
}
}

// Visual Studio 15.0 (2017) and later
try
{
Expand All @@ -142,8 +124,13 @@ private static List<IDEInfo> BuildIDEInfos()
if (inst2 == null)
continue;

// Only deal with VS2019+
if (!Version.TryParse(inst2.GetInstallationVersion(), out var version)
|| version.Major < 16)
continue;

var installationPath = inst2.GetInstallationPath();
var buildToolsPath = Path.Combine(installationPath, "MSBuild", "15.0", "Bin");
var buildToolsPath = Path.Combine(installationPath, "MSBuild", "Current", "Bin");
if (!Directory.Exists(buildToolsPath))
buildToolsPath = null;
var idePath = Path.Combine(installationPath, "Common7", "IDE");
Expand Down Expand Up @@ -177,11 +164,11 @@ private static List<IDEInfo> BuildIDEInfos()
continue;
}

var ideInfo = new IDEInfo(inst2.GetInstallationVersion(), displayName, installationPath, inst2.IsComplete())
var ideInfo = new IDEInfo(version, displayName, installationPath, inst2.IsComplete())
{
BuildToolsPath = buildToolsPath,
DevenvPath = devenvPath,
VsixInstallerVersion = VSIXInstallerVersion.VS2017AndFutureVersions,
VsixInstallerVersion = VSIXInstallerVersion.VS2019AndFutureVersions,
VsixInstallerPath = vsixInstallerPath,
};

Expand Down
6 changes: 3 additions & 3 deletions sources/core/Xenko.Core.Tasks/Xenko.Core.Tasks.csproj
Expand Up @@ -26,9 +26,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\deps\libgit2\LibGit2Sharp.dll</HintPath>
</Reference>
<PackageReference Include="Microsoft.Build" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.1.2" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.2" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="1.16.30">
<EmbedInteropTypes>True</EmbedInteropTypes>
</PackageReference>
Expand Down
Expand Up @@ -18,6 +18,6 @@
<PackageReference Include="Xenko.Particles" Version="<#= Xenko.Assets.XenkoConfig.GetLatestPackageDependency().Version #>" />
<PackageReference Include="Xenko.UI" Version="<#= Xenko.Assets.XenkoConfig.GetLatestPackageDependency().Version #>" />

<PackageReference Include="Xenko.Core.Assets.CompilerApp" Version="<#= Xenko.Assets.XenkoConfig.GetLatestPackageDependency().Version #>" PrivateAssets="contentfiles;analyzers" IncludeAssets="build" />
<PackageReference Include="Xenko.Core.Assets.CompilerApp" Version="<#= Xenko.Assets.XenkoConfig.GetLatestPackageDependency().Version #>" IncludeAssets="build;buildTransitive" />
</ItemGroup>
</Project>
Expand Up @@ -18,7 +18,7 @@
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="AvalonEdit" Version="5.0.4" />
<PackageReference Include="System.Reactive.Linq" Version="4.1.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="2.10.0" />
Expand Down
4 changes: 2 additions & 2 deletions sources/editor/Xenko.Editor/Xenko.Editor.csproj
Expand Up @@ -17,8 +17,8 @@
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.ComponentModel.Composition" />
<PackageReference Include="Microsoft.Build" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<Reference Include="System.ServiceModel" />
Expand Down
4 changes: 2 additions & 2 deletions sources/engine/Xenko.Assets/Xenko.Assets.csproj
Expand Up @@ -14,8 +14,8 @@
<DefineConstants>XENKO_VIDEO_FFMPEG;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="SharpDX.Direct2D1" Version="4.0.1" />
<!--PackageReference Include="Esent.Interop" Version="1.9.4" /-->
<PackageReference Include="FFmpeg.AutoGen" Version="3.4.0.2" />
Expand Down
3 changes: 0 additions & 3 deletions sources/prerequisites/BuildTools2017/vs_buildtools.exe

This file was deleted.

3 changes: 3 additions & 0 deletions sources/prerequisites/BuildTools2019/vs_buildtools.exe
Git LFS file not shown

0 comments on commit 105bd5c

Please sign in to comment.