re-restore test projects at their destination

since NuGet now stores the relative path to dependent projects in the lock file, projects need to be restored when they are moved
This commit is contained in:
Andrew Stanton-Nurse 2016-04-13 15:59:48 -07:00
parent 362397a945
commit 71d5738fff
6 changed files with 15 additions and 7 deletions

View file

@ -230,7 +230,6 @@ namespace Microsoft.DotNet.Cli.Build
public static BuildTargetResult CompileStage1(BuildTargetContext c) public static BuildTargetResult CompileStage1(BuildTargetContext c)
{ {
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test"));
if (Directory.Exists(Dirs.Stage1)) if (Directory.Exists(Dirs.Stage1))
{ {
@ -258,7 +257,6 @@ namespace Microsoft.DotNet.Cli.Build
var configuration = c.BuildContext.Get<string>("Configuration"); var configuration = c.BuildContext.Get<string>("Configuration");
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test"));
if (Directory.Exists(Dirs.Stage2)) if (Directory.Exists(Dirs.Stage2))
{ {

View file

@ -228,7 +228,7 @@ namespace Microsoft.DotNet.Cli.Build
{ {
var dotnet = DotNetCli.Stage0; var dotnet = DotNetCli.Stage0;
dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--infer-runtimes", "--fallbacksource", Dirs.Corehost) dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--fallbacksource", Dirs.Corehost)
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "src")) .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "src"))
.Execute() .Execute()
.EnsureSuccessful(); .EnsureSuccessful();

View file

@ -547,7 +547,7 @@ namespace Microsoft.DotNet.Tools.Build
private class ProjectComparer : IEqualityComparer<ProjectDescription> private class ProjectComparer : IEqualityComparer<ProjectDescription>
{ {
public bool Equals(ProjectDescription x, ProjectDescription y) => string.Equals(x.Identity.Name, y.Identity.Name); public bool Equals(ProjectDescription x, ProjectDescription y) => string.Equals(x.Identity.Name, y.Identity.Name, StringComparison.Ordinal);
public int GetHashCode(ProjectDescription obj) => obj.Identity.Name.GetHashCode(); public int GetHashCode(ProjectDescription obj) => obj.Identity.Name.GetHashCode();
} }

View file

@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
{ {
public class GivenAProjectToolsCommandResolver public class GivenAProjectToolsCommandResolver
{ {
private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetStandardApp15; private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetCoreApp10;
private static readonly string s_liveProjectDirectory = private static readonly string s_liveProjectDirectory =
Path.Combine(AppContext.BaseDirectory, "TestAssets/TestProjects/AppWithToolDependency"); Path.Combine(AppContext.BaseDirectory, "TestAssets/TestProjects/AppWithToolDependency");

View file

@ -21,7 +21,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
{ {
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets")); var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets"));
var testInstance = var testInstance =
testAssetManager.CreateTestInstance("ProjectWithTests", identifier: "ConsoleTests").WithLockFiles(); testAssetManager.CreateTestInstance("ProjectWithTests", identifier: "ConsoleTests");
_projectFilePath = Path.Combine(testInstance.TestRoot, "project.json"); _projectFilePath = Path.Combine(testInstance.TestRoot, "project.json");
var contexts = ProjectContext.CreateContextForEachFramework( var contexts = ProjectContext.CreateContextForEachFramework(
@ -29,6 +29,11 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
null, null,
PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers()); PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
// Restore the project again in the destination to resolve projects
// Since the lock file has project relative paths in it, those will be broken
// unless we re-restore
new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass();
_defaultOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0"); _defaultOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0");
} }

View file

@ -20,7 +20,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
public GivenThatWeWantToUseDotnetTestE2EInDesignTime() public GivenThatWeWantToUseDotnetTestE2EInDesignTime()
{ {
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets")); var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets"));
var testInstance = testAssetManager.CreateTestInstance("ProjectWithTests").WithLockFiles(); var testInstance = testAssetManager.CreateTestInstance("ProjectWithTests");
_projectFilePath = Path.Combine(testInstance.TestRoot, "project.json"); _projectFilePath = Path.Combine(testInstance.TestRoot, "project.json");
var contexts = ProjectContext.CreateContextForEachFramework( var contexts = ProjectContext.CreateContextForEachFramework(
@ -28,6 +28,11 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
null, null,
PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers()); PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
// Restore the project again in the destination to resolve projects
// Since the lock file has project relative paths in it, those will be broken
// unless we re-restore
new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass();
_outputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0"); _outputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0");
var buildCommand = new BuildCommand(_projectFilePath); var buildCommand = new BuildCommand(_projectFilePath);
var result = buildCommand.Execute(); var result = buildCommand.Execute();