Merge pull request #4265 from livarcocc/remove_projetjson_from_msbuild_template
Remove projetjson from msbuild template
This commit is contained in:
commit
a3a58423d1
21 changed files with 206 additions and 118 deletions
|
@ -4,14 +4,21 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
|
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
|
||||||
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
|
<OutputPath>bin\$(Configuration)</OutputPath>
|
||||||
<OutputPath>bin\$(Configuration)\netcoreapp1.0</OutputPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs" />
|
<Compile Include="**\*.cs" />
|
||||||
<None Include="project.json" />
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NETCore.App">
|
||||||
|
<Version>1.0.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.NETCore.Sdk">
|
||||||
|
<Version>1.0.0-alpha-20160930-1</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"frameworks": {
|
|
||||||
"netcoreapp1.0": {
|
|
||||||
"dependencies": {
|
|
||||||
"Microsoft.NETCore.Sdk": "1.0.0-alpha-20160923-4",
|
|
||||||
"Microsoft.NETCore.App": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"type": "platform"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,6 +19,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
||||||
new MigrateConfigurationsRule(),
|
new MigrateConfigurationsRule(),
|
||||||
new MigrateScriptsRule(),
|
new MigrateScriptsRule(),
|
||||||
new TemporaryMutateProjectJsonRule(),
|
new TemporaryMutateProjectJsonRule(),
|
||||||
|
new WorkaroundOptionsRule(),
|
||||||
new SaveOutputProjectRule()
|
new SaveOutputProjectRule()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
// TODO: https://github.com/dotnet/sdk/issues/67
|
// TODO: https://github.com/dotnet/sdk/issues/67
|
||||||
private AddPropertyTransform<CommonCompilerOptions> XmlDocTransformFilePath =>
|
private AddPropertyTransform<CommonCompilerOptions> XmlDocTransformFilePath =>
|
||||||
new AddPropertyTransform<CommonCompilerOptions>("DocumentationFile",
|
new AddPropertyTransform<CommonCompilerOptions>("DocumentationFile",
|
||||||
@"$(OutputPath)\$(AssemblyName).xml",
|
@"$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml",
|
||||||
compilerOptions => compilerOptions.GenerateXmlDocumentation != null && compilerOptions.GenerateXmlDocumentation.Value);
|
compilerOptions => compilerOptions.GenerateXmlDocumentation != null && compilerOptions.GenerateXmlDocumentation.Value);
|
||||||
|
|
||||||
private AddPropertyTransform<CommonCompilerOptions> OutputNameTransform =>
|
private AddPropertyTransform<CommonCompilerOptions> OutputNameTransform =>
|
||||||
|
|
|
@ -16,18 +16,10 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
public class MigrateTFMRule : IMigrationRule
|
public class MigrateTFMRule : IMigrationRule
|
||||||
{
|
{
|
||||||
private readonly ITransformApplicator _transformApplicator;
|
private readonly ITransformApplicator _transformApplicator;
|
||||||
private readonly AddPropertyTransform<NuGetFramework>[] _transforms;
|
|
||||||
|
|
||||||
public MigrateTFMRule(ITransformApplicator transformApplicator = null)
|
public MigrateTFMRule(ITransformApplicator transformApplicator = null)
|
||||||
{
|
{
|
||||||
_transformApplicator = transformApplicator ?? new TransformApplicator();
|
_transformApplicator = transformApplicator ?? new TransformApplicator();
|
||||||
|
|
||||||
_transforms = new AddPropertyTransform<NuGetFramework>[]
|
|
||||||
{
|
|
||||||
OutputPathTransform,
|
|
||||||
FrameworkIdentifierTransform,
|
|
||||||
FrameworkVersionTransform
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
|
public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
|
||||||
|
@ -36,25 +28,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
var propertyGroup = migrationRuleInputs.CommonPropertyGroup;
|
var propertyGroup = migrationRuleInputs.CommonPropertyGroup;
|
||||||
|
|
||||||
CleanExistingProperties(csproj);
|
CleanExistingProperties(csproj);
|
||||||
|
CleanExistingPackageReferences(csproj);
|
||||||
|
|
||||||
if (migrationRuleInputs.ProjectContexts.Count() > 1)
|
_transformApplicator.Execute(
|
||||||
{
|
FrameworksTransform.Transform(migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
||||||
_transformApplicator.Execute(
|
propertyGroup);
|
||||||
FrameworksTransform.Transform(migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
|
||||||
propertyGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var transform in _transforms)
|
|
||||||
{
|
|
||||||
_transformApplicator.Execute(
|
|
||||||
transform.Transform(migrationRuleInputs.DefaultProjectContext.TargetFramework),
|
|
||||||
propertyGroup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CleanExistingProperties(ProjectRootElement csproj)
|
private void CleanExistingProperties(ProjectRootElement csproj)
|
||||||
{
|
{
|
||||||
var existingPropertiesToRemove = new string[] { "TargetFrameworkIdentifier", "TargetFrameworkVersion" };
|
var existingPropertiesToRemove = new string[] { "TargetFrameworkIdentifier", "TargetFrameworkVersion", "TargetFrameworks" };
|
||||||
var properties = csproj.Properties.Where(p => existingPropertiesToRemove.Contains(p.Name));
|
var properties = csproj.Properties.Where(p => existingPropertiesToRemove.Contains(p.Name));
|
||||||
|
|
||||||
foreach (var property in properties)
|
foreach (var property in properties)
|
||||||
|
@ -63,6 +46,23 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: this is a hack right now to clean packagerefs. This is not the final resting place for this piece of code
|
||||||
|
// @brthor will move it to its final location as part of this PackageRef PR: https://github.com/dotnet/cli/pull/4261
|
||||||
|
private void CleanExistingPackageReferences(ProjectRootElement outputMSBuildProject)
|
||||||
|
{
|
||||||
|
var packageRefs = outputMSBuildProject
|
||||||
|
.Items
|
||||||
|
.Where(i => i.ItemType == "PackageReference" && i.Include != ConstantPackageNames.CSdkPackageName)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var packageRef in packageRefs)
|
||||||
|
{
|
||||||
|
var parent = packageRef.Parent;
|
||||||
|
packageRef.Parent.RemoveChild(packageRef);
|
||||||
|
parent.RemoveIfEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Taken from private NuGet.Frameworks method
|
// Taken from private NuGet.Frameworks method
|
||||||
// https://github.com/NuGet/NuGet.Client/blob/33b8f85a94b01f805f1e955f9b68992b297fad6e/src/NuGet.Core/NuGet.Frameworks/NuGetFramework.cs#L234
|
// https://github.com/NuGet/NuGet.Client/blob/33b8f85a94b01f805f1e955f9b68992b297fad6e/src/NuGet.Core/NuGet.Frameworks/NuGetFramework.cs#L234
|
||||||
private static string GetDisplayVersion(Version version)
|
private static string GetDisplayVersion(Version version)
|
||||||
|
@ -83,21 +83,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: When we have this inferred in the sdk targets, we won't need this
|
|
||||||
private AddPropertyTransform<NuGetFramework> OutputPathTransform =>
|
|
||||||
new AddPropertyTransform<NuGetFramework>("OutputPath",
|
|
||||||
f => $"bin/$(Configuration)/{f.GetShortFolderName()}",
|
|
||||||
f => true);
|
|
||||||
|
|
||||||
private AddPropertyTransform<NuGetFramework> FrameworkIdentifierTransform =>
|
|
||||||
new AddPropertyTransform<NuGetFramework>("TargetFrameworkIdentifier",
|
|
||||||
f => f.Framework,
|
|
||||||
f => true);
|
|
||||||
|
|
||||||
private AddPropertyTransform<NuGetFramework> FrameworkVersionTransform =>
|
|
||||||
new AddPropertyTransform<NuGetFramework>("TargetFrameworkVersion",
|
|
||||||
f => "v" + GetDisplayVersion(f.Version),
|
|
||||||
f => true);
|
|
||||||
private AddPropertyTransform<IEnumerable<NuGetFramework>> FrameworksTransform =>
|
private AddPropertyTransform<IEnumerable<NuGetFramework>> FrameworksTransform =>
|
||||||
new AddPropertyTransform<IEnumerable<NuGetFramework>>("TargetFrameworks",
|
new AddPropertyTransform<IEnumerable<NuGetFramework>>("TargetFrameworks",
|
||||||
frameworks => string.Join(";", frameworks.Select(f => f.GetShortFolderName())),
|
frameworks => string.Join(";", frameworks.Select(f => f.GetShortFolderName())),
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Microsoft.DotNet.ProjectJsonMigration.Transforms;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
|
{
|
||||||
|
public class WorkaroundOptionsRule : IMigrationRule
|
||||||
|
{
|
||||||
|
private readonly ITransformApplicator _transformApplicator;
|
||||||
|
|
||||||
|
private AddPropertyTransform<object> ProjectLockFileTransform =>
|
||||||
|
new AddPropertyTransform<object>("ProjectLockFile",
|
||||||
|
frameworks => "$(MSBuildProjectDirectory)/project.lock.json",
|
||||||
|
frameworks => true);
|
||||||
|
|
||||||
|
public WorkaroundOptionsRule(ITransformApplicator transformApplicator = null)
|
||||||
|
{
|
||||||
|
_transformApplicator = transformApplicator ?? new TransformApplicator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs)
|
||||||
|
{
|
||||||
|
var propertyGroup = migrationRuleInputs.CommonPropertyGroup;
|
||||||
|
|
||||||
|
_transformApplicator.Execute(ProjectLockFileTransform.Transform(string.Empty), propertyGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -66,6 +66,8 @@ namespace Microsoft.DotNet.TestFramework
|
||||||
foreach (string lockFile in Directory.GetFiles(_testAssetRoot, "project.lock.json", SearchOption.AllDirectories))
|
foreach (string lockFile in Directory.GetFiles(_testAssetRoot, "project.lock.json", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
string destinationLockFile = lockFile.Replace(_testAssetRoot, Path);
|
string destinationLockFile = lockFile.Replace(_testAssetRoot, Path);
|
||||||
|
Directory.CreateDirectory(System.IO.Path.GetDirectoryName(destinationLockFile));
|
||||||
|
|
||||||
File.Copy(lockFile, destinationLockFile, true);
|
File.Copy(lockFile, destinationLockFile, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Build.Construction;
|
using Microsoft.Build.Construction;
|
||||||
using Microsoft.DotNet.Cli;
|
|
||||||
using Microsoft.DotNet.ProjectJsonMigration;
|
using Microsoft.DotNet.ProjectJsonMigration;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.ProjectModel;
|
||||||
|
|
||||||
|
@ -37,8 +36,9 @@ namespace Microsoft.DotNet.Tools.Migrate
|
||||||
|
|
||||||
var msBuildTemplate = _templateFile != null ?
|
var msBuildTemplate = _templateFile != null ?
|
||||||
ProjectRootElement.TryOpen(_templateFile) : _temporaryDotnetNewProject.MSBuildProject;
|
ProjectRootElement.TryOpen(_templateFile) : _temporaryDotnetNewProject.MSBuildProject;
|
||||||
|
|
||||||
|
var sdkVersion = _sdkVersion ?? _temporaryDotnetNewProject.MSBuildProject.GetSdkVersion();
|
||||||
|
|
||||||
var sdkVersion = _sdkVersion ?? new ProjectJsonParser(_temporaryDotnetNewProject.ProjectJson).SdkPackageVersion;
|
|
||||||
EnsureNotNull(sdkVersion, "Null Sdk Version");
|
EnsureNotNull(sdkVersion, "Null Sdk Version");
|
||||||
|
|
||||||
foreach (var project in projectsToMigrate)
|
foreach (var project in projectsToMigrate)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Build.Construction;
|
||||||
|
using Microsoft.DotNet.ProjectJsonMigration;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Tools.Migrate
|
||||||
|
{
|
||||||
|
public static class ProjectRootElementExtensions
|
||||||
|
{
|
||||||
|
public static string GetSdkVersion(this ProjectRootElement projectRootElement)
|
||||||
|
{
|
||||||
|
//TODO: Temporarily pinning the SDK version for Migration. Once we have packageref migration we can remove this.
|
||||||
|
return "1.0.0-alpha-20160929-1";
|
||||||
|
|
||||||
|
// return projectRootElement
|
||||||
|
// .Items
|
||||||
|
// .Where(i => i.ItemType == "PackageReference")
|
||||||
|
// .First(i => i.Include == ConstantPackageNames.CSdkPackageName)
|
||||||
|
// .GetMetadataWithName("version").Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,8 @@
|
||||||
using Microsoft.Build.Construction;
|
using Microsoft.Build.Construction;
|
||||||
using Microsoft.DotNet.Cli;
|
using Microsoft.DotNet.Cli;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.DotNet.ProjectJsonMigration;
|
using Microsoft.DotNet.ProjectJsonMigration;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Tools.Migrate
|
namespace Microsoft.DotNet.Tools.Migrate
|
||||||
|
@ -17,13 +14,11 @@ namespace Microsoft.DotNet.Tools.Migrate
|
||||||
private readonly string _projectDirectory;
|
private readonly string _projectDirectory;
|
||||||
|
|
||||||
public ProjectRootElement MSBuildProject { get; }
|
public ProjectRootElement MSBuildProject { get; }
|
||||||
public JObject ProjectJson { get; }
|
|
||||||
|
|
||||||
public TemporaryDotnetNewTemplateProject()
|
public TemporaryDotnetNewTemplateProject()
|
||||||
{
|
{
|
||||||
_projectDirectory = CreateDotnetNewMSBuild(c_temporaryDotnetNewMSBuildProjectName);
|
_projectDirectory = CreateDotnetNewMSBuild(c_temporaryDotnetNewMSBuildProjectName);
|
||||||
MSBuildProject = GetMSBuildProject(_projectDirectory);
|
MSBuildProject = GetMSBuildProject(_projectDirectory);
|
||||||
ProjectJson = GetProjectJson(_projectDirectory);
|
|
||||||
|
|
||||||
Clean();
|
Clean();
|
||||||
}
|
}
|
||||||
|
@ -60,12 +55,6 @@ namespace Microsoft.DotNet.Tools.Migrate
|
||||||
return ProjectRootElement.Open(templateProjPath);
|
return ProjectRootElement.Open(templateProjPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JObject GetProjectJson(string temporaryDotnetNewMSBuildDirectory)
|
|
||||||
{
|
|
||||||
var projectJsonFile = Path.Combine(temporaryDotnetNewMSBuildDirectory, "project.json");
|
|
||||||
return JObject.Parse(File.ReadAllText(projectJsonFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RunCommand(string commandToExecute, IEnumerable<string> args, string workingDirectory)
|
private void RunCommand(string commandToExecute, IEnumerable<string> args, string workingDirectory)
|
||||||
{
|
{
|
||||||
var command = new DotNetCommandFactory()
|
var command = new DotNetCommandFactory()
|
||||||
|
|
|
@ -3,14 +3,22 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
|
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
|
||||||
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
|
<OutputPath>bin\$(Configuration)</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs" Exclude="$(GlobalExclude)" />
|
<Compile Include="**\*.cs" />
|
||||||
<EmbeddedResource Include="**\*.resx" Exclude="$(GlobalExclude)" />
|
<EmbeddedResource Include="**\*.resx" />
|
||||||
<None Include="project.json" />
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NETCore.App">
|
||||||
|
<Version>1.0.1</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.NETCore.Sdk">
|
||||||
|
<Version>1.0.0-alpha-20160930-1</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"dependencies": {},
|
|
||||||
"frameworks": {
|
|
||||||
"netcoreapp1.0": {
|
|
||||||
"dependencies": {
|
|
||||||
"Microsoft.NETCore.Sdk": "1.0.0-alpha-20160923-4",
|
|
||||||
"Microsoft.NETCore.App": {
|
|
||||||
"type": "platform",
|
|
||||||
"version": "1.0.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -94,10 +94,12 @@ namespace Microsoft.DotNet.Tools.New
|
||||||
private static void ReplaceProjectJsonTemplateValues(string projectDirectory)
|
private static void ReplaceProjectJsonTemplateValues(string projectDirectory)
|
||||||
{
|
{
|
||||||
string projectJsonFile = Path.Combine(projectDirectory, "project.json");
|
string projectJsonFile = Path.Combine(projectDirectory, "project.json");
|
||||||
|
string projectJsonTemplateFile = Path.Combine(projectDirectory, "project.json.template");
|
||||||
|
|
||||||
File.Move(
|
if(File.Exists(projectJsonTemplateFile))
|
||||||
Path.Combine(projectDirectory, "project.json.template"),
|
{
|
||||||
projectJsonFile);
|
File.Move(projectJsonTemplateFile, projectJsonFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReplaceFileTemplateNames(string projectDirectory)
|
private static void ReplaceFileTemplateNames(string projectDirectory)
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
"Microsoft.Net.Compilers.netcore": "2.0.0-beta6-60922-08",
|
"Microsoft.Net.Compilers.netcore": "2.0.0-beta6-60922-08",
|
||||||
"Microsoft.CodeAnalysis.Build.Tasks": "2.0.0-beta6-60922-08",
|
"Microsoft.CodeAnalysis.Build.Tasks": "2.0.0-beta6-60922-08",
|
||||||
"Microsoft.Cci": "4.0.0-rc3-24128-00",
|
"Microsoft.Cci": "4.0.0-rc3-24128-00",
|
||||||
"Microsoft.Composition": "1.0.30",
|
"Microsoft.NuGet.Build.Tasks": "1.0.0-alpha-000004",
|
||||||
"Microsoft.NuGet.Build.Tasks": "1.0.0-alpha-000004"
|
"Microsoft.Composition": "1.0.30"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"netcoreapp1.0": {
|
"netcoreapp1.0": {
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
||||||
.Should()
|
.Should()
|
||||||
.Pass();
|
.Pass();
|
||||||
|
|
||||||
new RestoreCommand()
|
new Restore3Command()
|
||||||
.WithWorkingDirectory(projectDirectory)
|
.WithWorkingDirectory(projectDirectory)
|
||||||
.Execute()
|
.Execute()
|
||||||
.Should()
|
.Should()
|
||||||
|
@ -33,9 +33,10 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
||||||
.Should()
|
.Should()
|
||||||
.Pass();
|
.Pass();
|
||||||
|
|
||||||
|
//TODO: https://github.com/dotnet/sdk/issues/187 - remove framework from below.
|
||||||
new Run3Command()
|
new Run3Command()
|
||||||
.WithWorkingDirectory(projectDirectory)
|
.WithWorkingDirectory(projectDirectory)
|
||||||
.ExecuteWithCapturedOutput()
|
.ExecuteWithCapturedOutput("--framework netcoreapp1.0")
|
||||||
.Should()
|
.Should()
|
||||||
.Pass()
|
.Pass()
|
||||||
.And
|
.And
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Migrating_Single_TFM_project_does_not_Populate_TargetFrameworks()
|
public void Migrating_Single_TFM_project_Populates_TargetFrameworks()
|
||||||
{
|
{
|
||||||
var testDirectory = Temp.CreateDirectory().Path;
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
@ -94,7 +94,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
||||||
Console.WriteLine(mockProj.RawXml);
|
Console.WriteLine(mockProj.RawXml);
|
||||||
|
|
||||||
mockProj.Properties.Count(p => p.Name == "TargetFrameworks").Should().Be(0);
|
mockProj.Properties.Count(p => p.Name == "TargetFrameworks").Should().Be(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
|
{
|
||||||
|
public sealed class Restore3Command : TestCommand
|
||||||
|
{
|
||||||
|
public Restore3Command()
|
||||||
|
: base("dotnet")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override CommandResult Execute(string args = "")
|
||||||
|
{
|
||||||
|
args = $"restore3 {args}";
|
||||||
|
return base.Execute(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override CommandResult ExecuteWithCapturedOutput(string args = "")
|
||||||
|
{
|
||||||
|
args = $"restore3 {args}";
|
||||||
|
return base.ExecuteWithCapturedOutput(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,11 +16,16 @@ namespace Microsoft.DotNet.Cli.Build3.Tests
|
||||||
{
|
{
|
||||||
var testAppName = "MSBuildTestApp";
|
var testAppName = "MSBuildTestApp";
|
||||||
var testInstance = TestAssetsManager
|
var testInstance = TestAssetsManager
|
||||||
.CreateTestInstance(testAppName)
|
.CreateTestInstance(testAppName);
|
||||||
.WithLockFiles();
|
|
||||||
|
|
||||||
var testProjectDirectory = testInstance.TestRoot;
|
var testProjectDirectory = testInstance.TestRoot;
|
||||||
|
|
||||||
|
new Restore3Command()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.Execute()
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
|
||||||
new Build3Command()
|
new Build3Command()
|
||||||
.WithWorkingDirectory(testProjectDirectory)
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
.Execute()
|
.Execute()
|
||||||
|
|
|
@ -29,7 +29,10 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
public void It_migrates_apps(string projectName)
|
public void It_migrates_apps(string projectName)
|
||||||
{
|
{
|
||||||
var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i").WithLockFiles().Path;
|
var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i").WithLockFiles().Path;
|
||||||
var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory);
|
|
||||||
|
CleanBinObj(projectDirectory);
|
||||||
|
|
||||||
|
var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory, projectName);
|
||||||
|
|
||||||
var outputsIdentical =
|
var outputsIdentical =
|
||||||
outputComparisonData.ProjectJsonBuildOutputs.SetEquals(outputComparisonData.MSBuildBuildOutputs);
|
outputComparisonData.ProjectJsonBuildOutputs.SetEquals(outputComparisonData.MSBuildBuildOutputs);
|
||||||
|
@ -79,7 +82,7 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
{
|
{
|
||||||
var projectDirectory =
|
var projectDirectory =
|
||||||
TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i").WithLockFiles().Path;
|
TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i").WithLockFiles().Path;
|
||||||
var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory);
|
var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory, projectName);
|
||||||
|
|
||||||
var outputsIdentical =
|
var outputsIdentical =
|
||||||
outputComparisonData.ProjectJsonBuildOutputs.SetEquals(outputComparisonData.MSBuildBuildOutputs);
|
outputComparisonData.ProjectJsonBuildOutputs.SetEquals(outputComparisonData.MSBuildBuildOutputs);
|
||||||
|
@ -100,7 +103,7 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
{
|
{
|
||||||
var projectDirectory =
|
var projectDirectory =
|
||||||
TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i").WithLockFiles().Path;
|
TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i").WithLockFiles().Path;
|
||||||
var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory);
|
var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory, Path.GetFileNameWithoutExtension(projectName));
|
||||||
|
|
||||||
var outputsIdentical =
|
var outputsIdentical =
|
||||||
outputComparisonData.ProjectJsonBuildOutputs.SetEquals(outputComparisonData.MSBuildBuildOutputs);
|
outputComparisonData.ProjectJsonBuildOutputs.SetEquals(outputComparisonData.MSBuildBuildOutputs);
|
||||||
|
@ -210,7 +213,8 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
File.Copy("NuGet.tempaspnetpatch.config", Path.Combine(projectDirectory, "NuGet.Config"));
|
File.Copy("NuGet.tempaspnetpatch.config", Path.Combine(projectDirectory, "NuGet.Config"));
|
||||||
Restore(projectDirectory);
|
Restore(projectDirectory);
|
||||||
|
|
||||||
var outputComparisonData = BuildProjectJsonMigrateBuildMSBuild(projectDirectory);
|
var outputComparisonData =
|
||||||
|
BuildProjectJsonMigrateBuildMSBuild(projectDirectory, Path.GetFileNameWithoutExtension(projectDirectory));
|
||||||
return outputComparisonData;
|
return outputComparisonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +231,7 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MigratedBuildComparisonData BuildProjectJsonMigrateBuildMSBuild(string projectDirectory)
|
private MigratedBuildComparisonData BuildProjectJsonMigrateBuildMSBuild(string projectDirectory, string projectName)
|
||||||
{
|
{
|
||||||
BuildProjectJson(projectDirectory);
|
BuildProjectJson(projectDirectory);
|
||||||
var projectJsonBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
|
var projectJsonBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
|
||||||
|
@ -238,7 +242,7 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
|
|
||||||
MigrateProject(projectDirectory);
|
MigrateProject(projectDirectory);
|
||||||
Restore(projectDirectory);
|
Restore(projectDirectory);
|
||||||
BuildMSBuild(projectDirectory);
|
BuildMSBuild(projectDirectory, projectName);
|
||||||
|
|
||||||
var msbuildBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
|
var msbuildBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
|
||||||
|
|
||||||
|
@ -259,7 +263,10 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
|
|
||||||
foreach (var dir in dirs)
|
foreach (var dir in dirs)
|
||||||
{
|
{
|
||||||
Directory.Delete(dir, true);
|
if(Directory.Exists(dir))
|
||||||
|
{
|
||||||
|
Directory.Delete(dir, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,13 +304,22 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
.Pass();
|
.Pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string BuildMSBuild(string projectDirectory, string configuration="Debug")
|
private void Restore3(string projectDirectory, string projectName)
|
||||||
|
{
|
||||||
|
new Restore3Command()
|
||||||
|
.WithWorkingDirectory(projectDirectory)
|
||||||
|
.Execute($"{projectName}.csproj")
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string BuildMSBuild(string projectDirectory, string projectName, string configuration="Debug")
|
||||||
{
|
{
|
||||||
DeleteXproj(projectDirectory);
|
DeleteXproj(projectDirectory);
|
||||||
|
|
||||||
var result = new Build3Command()
|
var result = new Build3Command()
|
||||||
.WithWorkingDirectory(projectDirectory)
|
.WithWorkingDirectory(projectDirectory)
|
||||||
.ExecuteWithCapturedOutput($"/p:Configuration={configuration}");
|
.ExecuteWithCapturedOutput($"{projectName}.csproj /p:Configuration={configuration}");
|
||||||
|
|
||||||
result
|
result
|
||||||
.Should()
|
.Should()
|
||||||
|
|
|
@ -16,17 +16,22 @@ namespace Microsoft.DotNet.Cli.Publish3.Tests
|
||||||
{
|
{
|
||||||
var testAppName = "MSBuildTestApp";
|
var testAppName = "MSBuildTestApp";
|
||||||
var testInstance = TestAssetsManager
|
var testInstance = TestAssetsManager
|
||||||
.CreateTestInstance(testAppName)
|
.CreateTestInstance(testAppName);
|
||||||
.WithLockFiles();
|
|
||||||
|
|
||||||
var testProjectDirectory = testInstance.TestRoot;
|
var testProjectDirectory = testInstance.TestRoot;
|
||||||
|
|
||||||
new Publish3Command()
|
new Restore3Command()
|
||||||
.WithWorkingDirectory(testProjectDirectory)
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
.Execute()
|
.Execute()
|
||||||
.Should()
|
.Should()
|
||||||
.Pass();
|
.Pass();
|
||||||
|
|
||||||
|
new Publish3Command()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.Execute("--framework netcoreapp1.0")
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
|
||||||
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
||||||
var outputDll = Path.Combine(testProjectDirectory, "bin", configuration, "netcoreapp1.0", "publish", $"{testAppName}.dll");
|
var outputDll = Path.Combine(testProjectDirectory, "bin", configuration, "netcoreapp1.0", "publish", $"{testAppName}.dll");
|
||||||
|
|
||||||
|
|
|
@ -13,20 +13,26 @@ namespace Microsoft.DotNet.Cli.Run3.Tests
|
||||||
{
|
{
|
||||||
var testAppName = "MSBuildTestApp";
|
var testAppName = "MSBuildTestApp";
|
||||||
var testInstance = TestAssetsManager
|
var testInstance = TestAssetsManager
|
||||||
.CreateTestInstance(testAppName)
|
.CreateTestInstance(testAppName);
|
||||||
.WithLockFiles();
|
|
||||||
|
|
||||||
var testProjectDirectory = testInstance.TestRoot;
|
var testProjectDirectory = testInstance.TestRoot;
|
||||||
|
|
||||||
|
new Restore3Command()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.Execute()
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
|
||||||
new Build3Command()
|
new Build3Command()
|
||||||
.WithWorkingDirectory(testProjectDirectory)
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
.Execute()
|
.Execute()
|
||||||
.Should()
|
.Should()
|
||||||
.Pass();
|
.Pass();
|
||||||
|
|
||||||
|
//TODO: https://github.com/dotnet/sdk/issues/187 - remove framework from below.
|
||||||
new Run3Command()
|
new Run3Command()
|
||||||
.WithWorkingDirectory(testProjectDirectory)
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
.ExecuteWithCapturedOutput()
|
.ExecuteWithCapturedOutput("--framework netcoreapp1.0")
|
||||||
.Should()
|
.Should()
|
||||||
.Pass()
|
.Pass()
|
||||||
.And
|
.And
|
||||||
|
@ -38,14 +44,20 @@ namespace Microsoft.DotNet.Cli.Run3.Tests
|
||||||
{
|
{
|
||||||
var testAppName = "MSBuildTestApp";
|
var testAppName = "MSBuildTestApp";
|
||||||
var testInstance = TestAssetsManager
|
var testInstance = TestAssetsManager
|
||||||
.CreateTestInstance(testAppName)
|
.CreateTestInstance(testAppName);
|
||||||
.WithLockFiles();
|
|
||||||
|
|
||||||
var testProjectDirectory = testInstance.TestRoot;
|
var testProjectDirectory = testInstance.TestRoot;
|
||||||
|
|
||||||
|
new Restore3Command()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.Execute()
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
|
||||||
|
//TODO: https://github.com/dotnet/sdk/issues/187 - remove framework from below.
|
||||||
new Run3Command()
|
new Run3Command()
|
||||||
.WithWorkingDirectory(testProjectDirectory)
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
.ExecuteWithCapturedOutput()
|
.ExecuteWithCapturedOutput("--framework netcoreapp1.0")
|
||||||
.Should()
|
.Should()
|
||||||
.Pass()
|
.Pass()
|
||||||
.And
|
.And
|
||||||
|
@ -57,11 +69,16 @@ namespace Microsoft.DotNet.Cli.Run3.Tests
|
||||||
{
|
{
|
||||||
var testAppName = "MSBuildTestApp";
|
var testAppName = "MSBuildTestApp";
|
||||||
var testInstance = TestAssetsManager
|
var testInstance = TestAssetsManager
|
||||||
.CreateTestInstance(testAppName)
|
.CreateTestInstance(testAppName);
|
||||||
.WithLockFiles();
|
|
||||||
|
|
||||||
var testProjectDirectory = testInstance.TestRoot;
|
var testProjectDirectory = testInstance.TestRoot;
|
||||||
|
|
||||||
|
new Restore3Command()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.Execute()
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
|
||||||
new Run3Command()
|
new Run3Command()
|
||||||
.WithWorkingDirectory(testProjectDirectory)
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
.ExecuteWithCapturedOutput("--framework netcoreapp1.0")
|
.ExecuteWithCapturedOutput("--framework netcoreapp1.0")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue