diff --git a/src/Microsoft.DotNet.ProjectModel/EnvironmentNames.cs b/src/Microsoft.DotNet.ProjectModel/EnvironmentNames.cs index 695eee323..803d4ff4a 100644 --- a/src/Microsoft.DotNet.ProjectModel/EnvironmentNames.cs +++ b/src/Microsoft.DotNet.ProjectModel/EnvironmentNames.cs @@ -6,5 +6,6 @@ namespace Microsoft.DotNet.ProjectModel public class EnvironmentNames { public static readonly string PackagesCache = "NUGET_PACKAGES"; + public static readonly string StrongNameKeyFile = "DOTNET_BUILD_STRONG_NAME_KEYFILE"; } } diff --git a/src/Microsoft.DotNet.Tools.Compiler/Program.cs b/src/Microsoft.DotNet.Tools.Compiler/Program.cs index 2f0659336..2012223c8 100644 --- a/src/Microsoft.DotNet.Tools.Compiler/Program.cs +++ b/src/Microsoft.DotNet.Tools.Compiler/Program.cs @@ -293,7 +293,14 @@ namespace Microsoft.DotNet.Tools.Compiler var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration); - if (!string.IsNullOrEmpty(compilationOptions.KeyFile)) + // Path to strong naming key in environment variable overrides path in project.json + var environmentKeyFile = Environment.GetEnvironmentVariable(EnvironmentNames.StrongNameKeyFile); + + if (!string.IsNullOrWhiteSpace(environmentKeyFile)) + { + compilationOptions.KeyFile = environmentKeyFile; + } + else if (!string.IsNullOrWhiteSpace(compilationOptions.KeyFile)) { // Resolve full path to key file compilationOptions.KeyFile = Path.GetFullPath(Path.Combine(context.ProjectFile.ProjectDirectory, compilationOptions.KeyFile));