fix key sign

This commit is contained in:
Bryan Thornbury 2016-10-04 15:49:35 -07:00
parent 7632cd3502
commit 148008d733
2 changed files with 19 additions and 1 deletions

View file

@ -32,6 +32,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
new AddPropertyTransform<CommonCompilerOptions>("SignAssembly", new AddPropertyTransform<CommonCompilerOptions>("SignAssembly",
"true", "true",
compilerOptions => !string.IsNullOrEmpty(compilerOptions.KeyFile)) compilerOptions => !string.IsNullOrEmpty(compilerOptions.KeyFile))
.WithMSBuildCondition(" '$(OS)' == 'Windows_NT' "),
new AddPropertyTransform<CommonCompilerOptions>("PublicSign",
"true",
compilerOptions => !string.IsNullOrEmpty(compilerOptions.KeyFile))
.WithMSBuildCondition(" '$(OS)' != 'Windows_NT' ")
}; };
private AddPropertyTransform<CommonCompilerOptions> DefineTransform => new AddPropertyTransform<CommonCompilerOptions>( private AddPropertyTransform<CommonCompilerOptions> DefineTransform => new AddPropertyTransform<CommonCompilerOptions>(

View file

@ -14,6 +14,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
private readonly string _propertyValue; private readonly string _propertyValue;
private readonly Func<T,string> _propertyValueFunc; private readonly Func<T,string> _propertyValueFunc;
private string _msbuildCondition = null;
public AddPropertyTransform(string propertyName, string propertyValue, Func<T,bool> condition) public AddPropertyTransform(string propertyName, string propertyValue, Func<T,bool> condition)
: base(condition) : base(condition)
{ {
@ -28,6 +30,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
_propertyValueFunc = propertyValueFunc; _propertyValueFunc = propertyValueFunc;
} }
public AddPropertyTransform<T> WithMSBuildCondition(string condition)
{
_msbuildCondition = condition;
return this;
}
public override ProjectPropertyElement ConditionallyTransform(T source) public override ProjectPropertyElement ConditionallyTransform(T source)
{ {
string propertyValue = GetPropertyValue(source); string propertyValue = GetPropertyValue(source);
@ -35,6 +43,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Transforms
var property = _propertyObjectGenerator.CreatePropertyElement(PropertyName); var property = _propertyObjectGenerator.CreatePropertyElement(PropertyName);
property.Value = propertyValue; property.Value = propertyValue;
if (!string.IsNullOrEmpty(_msbuildCondition))
{
property.Condition = _msbuildCondition;
}
return property; return property;
} }