From afa2d8e0992578ed943f2e5d4aa337e18c8810e9 Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Mon, 15 May 2017 11:48:03 +0200 Subject: [PATCH] Expose MsBuild Configuration and Platform setting This allows choosing other (than default) MsBuild configuration, e.g. MsBuild:Configuration=Release MsBuild:Platform=x64, especially usable for projects that are not using default (AnyCPU) platforms. This relates to #202. --- src/OmniSharp.MSBuild/Options/MSBuildOptions.cs | 2 ++ .../ProjectFile/ProjectFileInfo.PropertyNames.cs | 2 ++ src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/src/OmniSharp.MSBuild/Options/MSBuildOptions.cs b/src/OmniSharp.MSBuild/Options/MSBuildOptions.cs index 6fa8059e7e..dd302bf4f5 100644 --- a/src/OmniSharp.MSBuild/Options/MSBuildOptions.cs +++ b/src/OmniSharp.MSBuild/Options/MSBuildOptions.cs @@ -4,6 +4,8 @@ public class MSBuildOptions { public string ToolsVersion { get; set; } public string VisualStudioVersion { get; set; } + public string Configuration { get; set; } + public string Platform { get; set; } public bool EnablePackageAutoRestore { get; set; } public string MSBuildExtensionsPath { get; set; } diff --git a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.PropertyNames.cs b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.PropertyNames.cs index 7eb647986f..4e3c1f64fd 100644 --- a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.PropertyNames.cs +++ b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.PropertyNames.cs @@ -8,6 +8,7 @@ private static class PropertyNames public const string AssemblyName = nameof(AssemblyName); public const string AssemblyOriginatorKeyFile = nameof(AssemblyOriginatorKeyFile); public const string BuildProjectReferences = nameof(BuildProjectReferences); + public const string Configuration = nameof(Configuration); public const string DefineConstants = nameof(DefineConstants); public const string DesignTimeBuild = nameof(DesignTimeBuild); public const string DocumentationFile = nameof(DocumentationFile); @@ -17,6 +18,7 @@ private static class PropertyNames public const string MSBuildSDKsPath = nameof(MSBuildSDKsPath); public const string NoWarn = nameof(NoWarn); public const string OutputPath = nameof(OutputPath); + public const string Platform = nameof(Platform); public const string ProjectAssetsFile = nameof(ProjectAssetsFile); public const string ProjectGuid = nameof(ProjectGuid); public const string ProjectName = nameof(ProjectName); diff --git a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs index ad24d6febc..e4db054862 100644 --- a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs +++ b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs @@ -235,6 +235,18 @@ private static Dictionary GetGlobalProperties(MSBuildOptions opt userOptionValue: options.VisualStudioVersion, environmentValue: null); + globalProperties.AddPropertyIfNeeded( + logger, + PropertyNames.Configuration, + userOptionValue: options.Configuration, + environmentValue: null); + + globalProperties.AddPropertyIfNeeded( + logger, + PropertyNames.Platform, + userOptionValue: options.Platform, + environmentValue: null); + if (PlatformHelper.IsMono) { var monoXBuildFrameworksDirPath = PlatformHelper.MonoXBuildFrameworksDirPath;