a07ebe2e7b
Conflicts: TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj TestAssets/NonRestoredTestProjects/AppThrowingException/App/AppThrowingException.csproj TestAssets/NonRestoredTestProjects/AppThrowingException/AppDependingOnOtherAsTool/AppDependingOnOtherAsTool.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/EmptyItemGroup/EmptyItemGroup.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/Lib/Lib.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/MoreThanOne/a.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/MoreThanOne/b.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/Net452AndNetCoreApp10Lib/Net452AndNetCoreApp10Lib.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/Net45Lib/Net45Lib.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/ValidRef/ValidRef.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithDoubledRef/WithDoubledRef.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithExistingRefCondOnItem/WithExistingRefCondOnItem.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithExistingRefCondWhitespaces/WithExistingRefCondWhitespaces.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithRefCondNonUniform/WithRefCondNonUniform.csproj TestAssets/NonRestoredTestProjects/DotnetAddP2PProjects/WithRefNoCondNonUniform/WithRefNoCondNonUniform.csproj TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/AppWithDepOnTool/AppWithDepOnTool.csproj TestAssets/TestPackages/dotnet-dependency-context-test/dotnet-dependency-context-test.csproj TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj TestAssets/TestPackages/dotnet-portable/dotnet-portable.csproj TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj TestAssets/TestProjects/MSBuildAppWithMultipleFrameworks/MSBuildAppWithMultipleFrameworks.csproj TestAssets/TestProjects/MSBuildAppWithMultipleFrameworksAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/VSTestXunitDesktopAndNetCore.csproj TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj build_projects/Microsoft.DotNet.Cli.Build.Framework/Microsoft.DotNet.Cli.Build.Framework.csproj build_projects/dotnet-cli-build/dotnet-cli-build.csproj build_projects/shared-build-targets-utils/shared-build-targets-utils.csproj test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateTFMs.cs
149 lines
5 KiB
C#
149 lines
5 KiB
C#
// 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;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.DotNet.Cli.Run.Tests
|
|
{
|
|
public class GivenDotnetRunBuildsCsproj : TestBase
|
|
{
|
|
[Fact]
|
|
public void ItCanRunAMSBuildProject()
|
|
{
|
|
var testAppName = "MSBuildTestApp";
|
|
var testInstance = TestAssets.Get(testAppName)
|
|
.CreateInstance()
|
|
.WithSourceFiles();
|
|
|
|
var testProjectDirectory = testInstance.Root.FullName;
|
|
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.Execute("/p:SkipInvalidConfigurations=true")
|
|
.Should().Pass();
|
|
|
|
new BuildCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.Execute()
|
|
.Should().Pass();
|
|
|
|
new RunCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.ExecuteWithCapturedOutput()
|
|
.Should().Pass()
|
|
.And.HaveStdOutContaining("Hello World!");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItBuildsTheProjectBeforeRunning()
|
|
{
|
|
var testAppName = "MSBuildTestApp";
|
|
var testInstance = TestAssets.Get(testAppName)
|
|
.CreateInstance()
|
|
.WithSourceFiles();
|
|
|
|
var testProjectDirectory = testInstance.Root.FullName;
|
|
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.Execute("/p:SkipInvalidConfigurations=true")
|
|
.Should().Pass();
|
|
|
|
new RunCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.ExecuteWithCapturedOutput()
|
|
.Should().Pass()
|
|
.And.HaveStdOutContaining("Hello World!");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItCanRunAMSBuildProjectWhenSpecifyingAFramework()
|
|
{
|
|
var testAppName = "MSBuildTestApp";
|
|
var testInstance = TestAssets.Get(testAppName)
|
|
.CreateInstance()
|
|
.WithSourceFiles();
|
|
|
|
var testProjectDirectory = testInstance.Root.FullName;
|
|
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.Execute("/p:SkipInvalidConfigurations=true")
|
|
.Should().Pass();
|
|
|
|
new RunCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.ExecuteWithCapturedOutput("--framework netcoreapp2.0")
|
|
.Should().Pass()
|
|
.And.HaveStdOutContaining("Hello World!");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItRunsPortableAppsFromADifferentPathAfterBuilding()
|
|
{
|
|
var testInstance = TestAssets.Get("MSBuildTestApp")
|
|
.CreateInstance()
|
|
.WithSourceFiles()
|
|
.WithRestoreFiles();
|
|
|
|
new BuildCommand()
|
|
.WithWorkingDirectory(testInstance.Root)
|
|
.Execute()
|
|
.Should().Pass();
|
|
|
|
new RunCommand()
|
|
.WithWorkingDirectory(testInstance.Root)
|
|
.ExecuteWithCapturedOutput($"--no-build")
|
|
.Should().Pass()
|
|
.And.HaveStdOutContaining("Hello World!");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItRunsPortableAppsFromADifferentPathWithoutBuilding()
|
|
{
|
|
var testAppName = "MSBuildTestApp";
|
|
var testInstance = TestAssets.Get(testAppName)
|
|
.CreateInstance()
|
|
.WithSourceFiles()
|
|
.WithRestoreFiles();
|
|
|
|
var projectFile = testInstance.Root.GetFile(testAppName + ".csproj");
|
|
|
|
new RunCommand()
|
|
.WithWorkingDirectory(testInstance.Root.Parent)
|
|
.ExecuteWithCapturedOutput($"--project {projectFile.FullName}")
|
|
.Should().Pass()
|
|
.And.HaveStdOutContaining("Hello World!");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItRunsAppWhenRestoringToSpecificPackageDirectory()
|
|
{
|
|
var rootPath = TestAssets.CreateTestDirectory().FullName;
|
|
|
|
string dir = "pkgs";
|
|
string args = $"--packages {dir}";
|
|
|
|
string newArgs = $"console -o \"{rootPath}\"";
|
|
new NewCommandShim()
|
|
.WithWorkingDirectory(rootPath)
|
|
.Execute(newArgs)
|
|
.Should()
|
|
.Pass();
|
|
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(rootPath)
|
|
.Execute(args)
|
|
.Should()
|
|
.Pass();
|
|
|
|
new RunCommand()
|
|
.WithWorkingDirectory(rootPath)
|
|
.ExecuteWithCapturedOutput()
|
|
.Should().Pass()
|
|
.And.HaveStdOutContaining("Hello World");
|
|
}
|
|
}
|
|
}
|