本文整理汇总了C#中Microsoft.DotNet.Tools.Test.Utilities.BuildCommand类的典型用法代码示例。如果您正苦于以下问题:C# BuildCommand类的具体用法?C# BuildCommand怎么用?C# BuildCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildCommand类属于Microsoft.DotNet.Tools.Test.Utilities命名空间,在下文中一共展示了BuildCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
private void Setup([CallerMemberName] string callingMethod = "")
{
var testInstance = TestAssetsManager.CreateTestInstance(Path.Combine("ProjectsWithTests", "MultipleFrameworkProject"), callingMethod);
_projectFilePath = Path.Combine(testInstance.TestRoot, "project.json");
var contexts = ProjectContext.CreateContextForEachFramework(
_projectFilePath,
null,
RuntimeEnvironmentRidExtensions.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();
_netCoreAppOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0");
var buildCommand = new BuildCommand(_projectFilePath);
var result = buildCommand.Execute($"-f netcoreapp1.0 -o {_netCoreAppOutputPath}");
result.Should().Pass();
if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows)
{
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
_net451OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net451", rid);
result = buildCommand.Execute($"-f net451 -r {rid} -o {_net451OutputPath}");
result.Should().Pass();
}
}
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:29,代码来源:GivenThatWeWantToUseDotnetTestE2EInDesignTimeForMultipleTFms.cs
示例2: XmlDocumentationFileIsGenerated
public void XmlDocumentationFileIsGenerated()
{
// create unique directories in the 'temp' folder
var root = Temp.CreateDirectory();
var testLibDir = root.CreateDirectory("TestLibrary");
// copy projects to the temp dir and restore them
CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestLibrary"), testLibDir);
RunRestore(testLibDir.Path);
// run compile
var outputDir = Path.Combine(testLibDir.Path, "bin");
var testProject = GetProjectPath(testLibDir);
var buildCommand = new BuildCommand(testProject, output: outputDir);
var result = buildCommand.ExecuteWithCapturedOutput();
result.Should().Pass();
// Should have triggered some compiler warnings about missing XML doc comments
Assert.True(result.StdErr.Contains("warning CS1591"));
// verify the output xml file
var outputXml = Path.Combine(outputDir, "TestLibrary.xml");
Assert.True(File.Exists(outputXml));
Assert.Contains("Gets the message from the helper", File.ReadAllText(outputXml));
}
示例3: BuildAndTest
private static void BuildAndTest(string testRoot)
{
string appName = Path.GetFileName(testRoot);
var result = new BuildCommand(
projectPath: testRoot)
.ExecuteWithCapturedOutput();
result.Should().Pass();
var outputBase = new DirectoryInfo(Path.Combine(testRoot, "bin", "Debug"));
var netcoreAppOutput = outputBase.Sub("netcoreapp1.0");
netcoreAppOutput.Should()
.Exist().And
.OnlyHaveFiles(new[]
{
$"{appName}.deps.json",
$"{appName}.dll",
$"{appName}.pdb",
$"{appName}.runtimeconfig.json",
$"{appName}.runtimeconfig.dev.json"
});
}
示例4: BuildingAPortableProjectProducesDepsFile
public void BuildingAPortableProjectProducesDepsFile()
{
var testInstance = TestAssetsManager.CreateTestInstance("BuildTestPortableProject")
.WithLockFiles();
var result = new BuildCommand(
projectPath: testInstance.TestRoot,
forcePortable: true)
.ExecuteWithCapturedOutput();
result.Should().Pass();
var outputBase = new DirectoryInfo(Path.Combine(testInstance.TestRoot, "bin", "Debug"));
var netstandardappOutput = outputBase.Sub("netstandardapp1.5");
netstandardappOutput.Should()
.Exist().And
.HaveFiles(new[]
{
"BuildTestPortableProject.deps",
"BuildTestPortableProject.deps.json",
"BuildTestPortableProject.dll",
"BuildTestPortableProject.pdb"
});
}
示例5: XmlDocumentationFileIsGenerated
public void XmlDocumentationFileIsGenerated()
{
// create unique directories in the 'temp' folder
var root = Temp.CreateDirectory();
root.CopyFile(Path.Combine(_testProjectsRoot, "global.json"));
var testLibDir = root.CreateDirectory("TestLibrary");
// copy projects to the temp dir and restore them
CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestLibrary"), testLibDir);
RunRestore(testLibDir.Path);
// run compile
var outputDir = Path.Combine(testLibDir.Path, "bin");
var testProject = GetProjectPath(testLibDir);
var buildCommand = new BuildCommand(testProject, output: outputDir);
var result = buildCommand.ExecuteWithCapturedOutput();
result.Should().Pass();
// verify the output xml file
var outputXml = Path.Combine(outputDir, "Debug", "dnxcore50", "TestLibrary.xml");
Console.WriteLine("OUTPUT XML PATH: " + outputXml);
Assert.True(File.Exists(outputXml));
Assert.Contains("Gets the message from the helper", File.ReadAllText(outputXml));
}
示例6: TestDotnetIncrementalBuild
public void TestDotnetIncrementalBuild()
{
// first build
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, framework: NetCoreAppTfm);
buildCommand.Execute().Should().Pass();
TestOutputExecutable(OutputDirectory, buildCommand.GetPortableOutputName(), s_expectedOutput);
var binariesOutputDirectory = GetCompilationOutputPath(OutputDirectory, false);
var latestWriteTimeFirstBuild = GetLastWriteTimeUtcOfDirectoryFiles(
binariesOutputDirectory);
// second build; should get skipped (incremental because no inputs changed)
buildCommand.Execute().Should().Pass();
TestOutputExecutable(OutputDirectory, buildCommand.GetPortableOutputName(), s_expectedOutput);
var latestWriteTimeUtcSecondBuild = GetLastWriteTimeUtcOfDirectoryFiles(
binariesOutputDirectory);
Assert.Equal(latestWriteTimeFirstBuild, latestWriteTimeUtcSecondBuild);
TouchSourceFileInDirectory(TestDirectory);
// third build; should get compiled because the source file got touched
buildCommand.Execute().Should().Pass();
TestOutputExecutable(OutputDirectory, buildCommand.GetPortableOutputName(), s_expectedOutput);
var latestWriteTimeUtcThirdBuild = GetLastWriteTimeUtcOfDirectoryFiles(
binariesOutputDirectory);
Assert.NotEqual(latestWriteTimeUtcSecondBuild, latestWriteTimeUtcThirdBuild);
}
示例7: It_resolves_desktop_apps_when_configuration_is_Debug
public void It_resolves_desktop_apps_when_configuration_is_Debug()
{
var configuration = "Debug";
var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable")
.WithLockFiles();
var buildCommand = new BuildCommand(
Path.Combine(testInstance.TestRoot, "project.json"),
configuration: configuration)
.ExecuteWithCapturedOutput()
.Should()
.Pass();
var context = ProjectContext.Create(testInstance.TestRoot, s_desktopTestFramework);
var factory = new ProjectDependenciesCommandFactory(
s_desktopTestFramework,
configuration,
null,
null,
testInstance.TestRoot);
var command = factory.Create("dotnet-desktop-and-portable", null);
command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
}
示例8: TestDotnetBuild
public void TestDotnetBuild()
{
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, framework: NetCoreAppTfm);
buildCommand.Execute().Should().Pass();
TestOutputExecutable(OutputDirectory, buildCommand.GetPortableOutputName(), s_expectedOutput);
}
示例9: TestDotnetBuild
public void TestDotnetBuild()
{
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory);
buildCommand.Execute().Should().Pass();
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName());
}
示例10: TestDotnetBuild
public void TestDotnetBuild()
{
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, framework: DefaultFramework);
buildCommand.Execute().Should().Pass();
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
}
示例11: It_skips_build_when_the_no_build_flag_is_passed
public void It_skips_build_when_the_no_build_flag_is_passed()
{
var buildCommand = new BuildCommand(_projectFilePath);
var result = buildCommand.Execute();
result.Should().Pass();
var testCommand = new DotnetTestCommand();
result = testCommand.Execute($"{_projectFilePath} -o {_defaultOutputPath} --no-build");
result.Should().Pass();
}
示例12: BuildSingleProject
public void BuildSingleProject(TestInstance instance)
{
foreach (var iteration in Benchmark.Iterations)
{
var buildCommand = new BuildCommand(instance.TestRoot, buildProfile: false);
using (iteration.StartMeasurement())
{
buildCommand.Execute().Should().Pass();
}
TouchSource(instance.TestRoot);
}
}
示例13: Compilation_of_valid_app_should_succeed
public void Compilation_of_valid_app_should_succeed()
{
var testProject = Path.Combine(s_testProjectsRoot, "TestAppWithArgs", "project.json");
var buildCommand = new BuildCommand(testProject);
var oldDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(Path.GetDirectoryName(testProject));
buildCommand.Execute().Should().Pass();
Directory.SetCurrentDirectory(oldDirectory);
}
示例14: Setup
private void Setup(string project, ref string projectDir, ref string buildDir, ref string publishDir)
{
projectDir = Path.Combine(_testInstance.TestRoot, project);
buildDir = Path.Combine(projectDir, _buildRelativePath);
publishDir = Path.Combine(projectDir, "publish");
var buildCommand = new BuildCommand(projectDir, framework: Framework, runtime: _Runtime);
buildCommand.Execute().Should().Pass();
var publishCommand = new PublishCommand(projectDir, output: publishDir, framework: Framework, runtime: _Runtime);
publishCommand.Execute().Should().Pass();
}
示例15: Test_Build_Project_with_Resources_with_Space_in_Path_Should_Succeed
public void Test_Build_Project_with_Resources_with_Space_in_Path_Should_Succeed()
{
var spaceBufferDirectory = _root.CreateDirectory("space directory");
var testAppDir = spaceBufferDirectory.CreateDirectory("TestProjectWithResource");
CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestProjectWithResource"), testAppDir);
var testProject = GetProjectPath(testAppDir);
var buildCommand = new BuildCommand(testProject);
buildCommand.Execute().Should().Pass();
}