Merge pull request #3983 from brthor/brthor/runtimeoptions

Add support for user runtimeconfig
This commit is contained in:
Bryan Thornbury 2016-08-03 10:51:33 -07:00 committed by GitHub
commit 308f49c32e
2 changed files with 10 additions and 10 deletions

View file

@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Core.Build.Tasks
public string RuntimeConfigDevPath { get; set; }
public string RawRuntimeOptions { get; set; }
public string UserRuntimeConfig { get; set; }
private LockFile LockFile { get; set; }
@ -52,7 +52,7 @@ namespace Microsoft.DotNet.Core.Build.Tasks
config.RuntimeOptions = new RuntimeOptions();
AddFramework(config.RuntimeOptions);
AddRuntimeOptions(config.RuntimeOptions);
AddUserRuntimeOptions(config.RuntimeOptions);
WriteToJsonFile(RuntimeConfigPath, config);
}
@ -76,14 +76,16 @@ namespace Microsoft.DotNet.Core.Build.Tasks
}
}
private void AddRuntimeOptions(RuntimeOptions runtimeOptions)
private void AddUserRuntimeOptions(RuntimeOptions runtimeOptions)
{
if (string.IsNullOrEmpty(RawRuntimeOptions))
if (string.IsNullOrEmpty(UserRuntimeConfig) || !File.Exists(UserRuntimeConfig))
{
return;
}
var runtimeOptionsFromProject = JObject.Parse(RawRuntimeOptions);
var rawRuntimeOptions = File.ReadAllText(UserRuntimeConfig);
var runtimeOptionsFromProject = JObject.Parse(rawRuntimeOptions);
foreach (var runtimeOption in runtimeOptionsFromProject)
{
runtimeOptions.RawOptions.Add(runtimeOption.Key, runtimeOption.Value);

View file

@ -7,7 +7,7 @@
<!-- If the build task directory doesn't exist (since we aren't in a NuGet package), load the task assembly in the tools path -->
<MicrosoftDotNetCoreBuildTasksDirectory Condition=" !Exists('$(MicrosoftDotNetCoreBuildTasksDirectory)') ">$(MSBuildToolsPath)/</MicrosoftDotNetCoreBuildTasksDirectory>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup>
<!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
@ -20,6 +20,7 @@
<PropertyGroup>
<GenerateRuntimeConfigurationFiles Condition=" '$(GenerateRuntimeConfigurationFiles)' == '' and '$(OutputType)' == 'exe' ">true</GenerateRuntimeConfigurationFiles>
<UserRuntimeConfig Condition=" '$(UserRuntimeConfig)' == '' ">$(MSBuildProjectDirectory)/runtimeconfig.template.json</UserRuntimeConfig>
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">1.0.0</VersionPrefix>
<VersionSuffix Condition=" '$(VersionSuffix)' == '' "></VersionSuffix>
<Version Condition=" '$(Version)' == '' and '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version>
@ -63,13 +64,10 @@
<Target Name="GenerateRuntimeConfigurationFiles"
Condition=" '$(GenerateRuntimeConfigurationFiles)' == 'true'">
<!--
TODO: Get RawRuntimeOptions from where it lives in the MSBuild world
-->
<GenerateRuntimeConfigurationFiles LockFilePath="$(MSBuildProjectDirectory)/project.lock.json"
RuntimeConfigPath="$(TargetDir)/$(AssemblyName).runtimeconfig.json"
RuntimeConfigDevPath="$(TargetDir)/$(AssemblyName).runtimeconfig.dev.json"
RawRuntimeOptions="" />
UserRuntimeConfig="$(UserRuntimeConfig)" />
</Target>