2016-04-25 17:56:05 +00:00
|
|
|
// 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 System.IO;
|
2016-11-14 22:26:03 +00:00
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
2016-04-25 17:56:05 +00:00
|
|
|
using Microsoft.DotNet.TestFramework;
|
2016-04-28 23:30:32 +00:00
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
2016-10-28 01:46:43 +00:00
|
|
|
using NuGet.Frameworks;
|
2016-04-25 17:56:05 +00:00
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
namespace Microsoft.DotNet.BindingRedirects.Tests
|
2016-04-25 17:56:05 +00:00
|
|
|
{
|
|
|
|
public class TestSetupFixture : TestBase
|
|
|
|
{
|
2016-10-28 01:46:43 +00:00
|
|
|
private readonly NuGetFramework Framework = NuGet.Frameworks.FrameworkConstants.CommonFrameworks.Net46;
|
2016-04-25 17:56:05 +00:00
|
|
|
private const string Config = "Debug";
|
|
|
|
private const string AppWithConfig = "AppWithRedirectsAndConfig";
|
|
|
|
private const string AppWithoutConfig = "AppWithRedirectsNoConfig";
|
|
|
|
|
2016-04-28 23:30:32 +00:00
|
|
|
private string _Runtime = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
2016-04-25 17:56:05 +00:00
|
|
|
private string _appWithConfigProjectRoot;
|
|
|
|
private string _appWithoutConfigProjectRoot;
|
2016-11-14 22:26:03 +00:00
|
|
|
private TestAssetInstance _testInstance;
|
2016-04-25 17:56:05 +00:00
|
|
|
|
|
|
|
public string AppWithConfigProjectRoot { get { return _appWithConfigProjectRoot; } }
|
|
|
|
public string AppWithoutConfigProjectRoot { get { return _appWithoutConfigProjectRoot; } }
|
|
|
|
|
|
|
|
public TestSetupFixture()
|
|
|
|
{
|
2016-11-14 22:26:03 +00:00
|
|
|
_testInstance = TestAssets.Get("DesktopTestProjects", "BindingRedirectSample")
|
|
|
|
.CreateInstance()
|
|
|
|
.WithSourceFiles()
|
|
|
|
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages);
|
2016-04-25 17:56:05 +00:00
|
|
|
|
2016-11-14 22:26:03 +00:00
|
|
|
_appWithConfigProjectRoot = Setup(AppWithConfig);
|
|
|
|
_appWithoutConfigProjectRoot = Setup(AppWithoutConfig);
|
2016-04-25 17:56:05 +00:00
|
|
|
}
|
|
|
|
|
2016-11-14 22:26:03 +00:00
|
|
|
private string Setup(string project)
|
2016-04-25 17:56:05 +00:00
|
|
|
{
|
2016-11-14 22:26:03 +00:00
|
|
|
string projectDir = Path.Combine(_testInstance.Root.FullName, project);
|
|
|
|
string publishDir = Path.Combine(projectDir, "publish");
|
|
|
|
|
|
|
|
new RestoreCommand()
|
|
|
|
.WithWorkingDirectory(projectDir)
|
|
|
|
.WithRuntime(_Runtime)
|
|
|
|
.ExecuteWithCapturedOutput()
|
|
|
|
.Should().Pass();
|
2016-04-25 17:56:05 +00:00
|
|
|
|
2016-11-14 22:26:03 +00:00
|
|
|
new BuildCommand()
|
2016-10-28 01:46:43 +00:00
|
|
|
.WithWorkingDirectory(projectDir)
|
|
|
|
.WithFramework(Framework)
|
|
|
|
.WithRuntime(_Runtime)
|
|
|
|
.Execute()
|
|
|
|
.Should().Pass();
|
2016-04-25 17:56:05 +00:00
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
new PublishCommand()
|
|
|
|
.WithWorkingDirectory(projectDir)
|
|
|
|
.WithOutput(publishDir)
|
|
|
|
.WithFramework(Framework)
|
|
|
|
.WithRuntime(_Runtime)
|
|
|
|
.Execute()
|
|
|
|
.Should().Pass();
|
2016-11-14 22:26:03 +00:00
|
|
|
|
|
|
|
return projectDir;
|
2016-04-25 17:56:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|