Updating the msbuild templates in the CLI to use TargetFramework (singular).
This commit is contained in:
parent
c62433a3e6
commit
e2e72a9662
8 changed files with 48 additions and 20 deletions
|
@ -1,11 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
|
||||
<OutputPath>bin\$(Configuration)</OutputPath>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -17,7 +15,7 @@
|
|||
<Version>1.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161010-1</Version>
|
||||
<Version>1.0.0-alpha-20161012-3</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
|
||||
<OutputPath>bin\$(Configuration)</OutputPath>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -17,7 +15,7 @@
|
|||
<Version>1.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161010-1</Version>
|
||||
<Version>1.0.0-alpha-20161012-3</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="dotnet-portable">
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
{
|
||||
return _project
|
||||
.AllEvaluatedProperties
|
||||
.Where(p => p.Name.Equals("ProjectLockFile"))
|
||||
.Where(p => p.Name.Equals("ProjectAssetsFile"))
|
||||
.Select(p => p.EvaluatedValue)
|
||||
.FirstOrDefault(p => File.Exists(p));
|
||||
}
|
||||
|
|
|
@ -30,14 +30,32 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
|||
CleanExistingProperties(csproj);
|
||||
CleanExistingPackageReferences(csproj);
|
||||
|
||||
_transformApplicator.Execute(
|
||||
FrameworksTransform.Transform(migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
||||
propertyGroup);
|
||||
if(migrationRuleInputs.ProjectContexts.Count() == 1)
|
||||
{
|
||||
_transformApplicator.Execute(
|
||||
FrameworkTransform.Transform(
|
||||
migrationRuleInputs.ProjectContexts.Single().TargetFramework),
|
||||
propertyGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
_transformApplicator.Execute(
|
||||
FrameworksTransform.Transform(
|
||||
migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
||||
propertyGroup);
|
||||
}
|
||||
}
|
||||
|
||||
private void CleanExistingProperties(ProjectRootElement csproj)
|
||||
{
|
||||
var existingPropertiesToRemove = new string[] { "TargetFrameworkIdentifier", "TargetFrameworkVersion", "TargetFrameworks" };
|
||||
var existingPropertiesToRemove = new string[]
|
||||
{
|
||||
"TargetFrameworkIdentifier",
|
||||
"TargetFrameworkVersion",
|
||||
"TargetFrameworks",
|
||||
"TargetFramework"
|
||||
};
|
||||
|
||||
var properties = csproj.Properties.Where(p => existingPropertiesToRemove.Contains(p.Name));
|
||||
|
||||
foreach (var property in properties)
|
||||
|
@ -84,8 +102,15 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
|||
}
|
||||
|
||||
private AddPropertyTransform<IEnumerable<NuGetFramework>> FrameworksTransform =>
|
||||
new AddPropertyTransform<IEnumerable<NuGetFramework>>("TargetFrameworks",
|
||||
new AddPropertyTransform<IEnumerable<NuGetFramework>>(
|
||||
"TargetFrameworks",
|
||||
frameworks => string.Join(";", frameworks.Select(f => f.GetShortFolderName())),
|
||||
frameworks => true);
|
||||
|
||||
private AddPropertyTransform<NuGetFramework> FrameworkTransform =>
|
||||
new AddPropertyTransform<NuGetFramework>(
|
||||
"TargetFramework",
|
||||
framework => framework.GetShortFolderName(),
|
||||
framework => true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard1.4</TargetFrameworks>
|
||||
<TargetFramework>netstandard1.4</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -107,6 +107,8 @@ namespace Microsoft.DotNet.Tools.Restore3
|
|||
msbuildArgs.Add($"/p:RestoreRecursive=false");
|
||||
}
|
||||
|
||||
AddWorkaroundForOutputValidationIssue(msbuildArgs);
|
||||
|
||||
// Add in arguments
|
||||
msbuildArgs.AddRange(argRoot.Values);
|
||||
|
||||
|
@ -118,5 +120,10 @@ namespace Microsoft.DotNet.Tools.Restore3
|
|||
|
||||
return cmd.Execute(args);
|
||||
}
|
||||
|
||||
private static void AddWorkaroundForOutputValidationIssue(IList<string> msbuildArgs)
|
||||
{
|
||||
msbuildArgs.Add("/p:SkipInvalidConfigurations=true;_InvalidConfigurationWarning=false");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Migrating_Single_TFM_project_Populates_TargetFrameworks()
|
||||
public void Migrating_Single_TFM_project_Populates_TargetFramework()
|
||||
{
|
||||
var testDirectory = Temp.CreateDirectory().Path;
|
||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||
|
@ -94,7 +94,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
||||
Console.WriteLine(mockProj.RawXml);
|
||||
|
||||
mockProj.Properties.Count(p => p.Name == "TargetFrameworks").Should().Be(1);
|
||||
mockProj.Properties.Count(p => p.Name == "TargetFramework").Should().Be(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue