本文整理汇总了C#中Microsoft.DotNet.Tools.Test.Utilities.BuildCommand.ExecuteWithCapturedOutput方法的典型用法代码示例。如果您正苦于以下问题:C# BuildCommand.ExecuteWithCapturedOutput方法的具体用法?C# BuildCommand.ExecuteWithCapturedOutput怎么用?C# BuildCommand.ExecuteWithCapturedOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.DotNet.Tools.Test.Utilities.BuildCommand
的用法示例。
在下文中一共展示了BuildCommand.ExecuteWithCapturedOutput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例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: LibraryWithAnalyzer
public void LibraryWithAnalyzer()
{
var root = Temp.CreateDirectory();
var testLibDir = root.CreateDirectory("TestLibraryWithAnalyzer");
CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestLibraryWithAnalyzer"), testLibDir);
// run compile
var outputDir = Path.Combine(testLibDir.Path, "bin");
var testProject = GetProjectPath(testLibDir);
var buildCmd = new BuildCommand(testProject, output: outputDir);
var result = buildCmd.ExecuteWithCapturedOutput();
result.Should().Pass();
Assert.Contains("CA1018", result.StdOut);
}
示例4: It_builds_projects_with_Unicode_in_path
public void It_builds_projects_with_Unicode_in_path()
{
var testInstance = TestAssetsManager
.CreateTestInstance("TestAppWithUnicodéPath")
.WithLockFiles();
var testProjectDirectory = testInstance.TestRoot;
var buildCommand = new BuildCommand("");
buildCommand.WorkingDirectory = testProjectDirectory;
buildCommand.ExecuteWithCapturedOutput()
.Should()
.Pass();
}
示例5: BuildProject
protected CommandResult BuildProject(string projectFile, bool noDependencies = false, bool noIncremental = false, bool expectBuildFailure = false)
{
var buildCommand = new BuildCommand(projectFile, output: GetOutputDir(), framework: "dnxcore50", noIncremental: noIncremental, noDependencies : noDependencies);
var result = buildCommand.ExecuteWithCapturedOutput();
if (!expectBuildFailure)
{
result.Should().Pass();
TestOutputExecutable(GetOutputExePath(), buildCommand.GetOutputExecutableName(), ExpectedOutput);
}
else
{
result.Should().Fail();
}
return result;
}
示例6: WrappedProjectFilesResolvedCorrectly
public void WrappedProjectFilesResolvedCorrectly()
{
var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithWrapperProjectDependency")
.WithBuildArtifacts()
.WithLockFiles();
var root = testInstance.TestRoot;
// run compile
var outputDir = Path.Combine(root, "bin");
var testProject = ProjectUtils.GetProjectJson(root, "TestApp");
var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
var result = buildCommand.ExecuteWithCapturedOutput();
result.Should().Pass();
new DirectoryInfo(outputDir).Should()
.HaveFiles(new [] { "TestLibrary.dll", "TestLibrary.pdb" });
}
示例7: TestRebuildWhenVersionSuffixChanged
public void TestRebuildWhenVersionSuffixChanged()
{
var testInstance = TestAssetsManager.CreateTestInstance("TestSimpleIncrementalApp")
.WithLockFiles();
// Build with Version Suffix 1
var command = new BuildCommand(testInstance.TestRoot, versionSuffix: "1");
var result = command.ExecuteWithCapturedOutput();
// Verify the result
result.Should().HaveCompiledProject("TestSimpleIncrementalApp", ".NETCoreApp,Version=v1.0");
// Build with Version Suffix 2
command = new BuildCommand(testInstance.TestRoot, versionSuffix: "2");
result = command.ExecuteWithCapturedOutput();
// Verify the result
result.Should().HaveCompiledProject("TestSimpleIncrementalApp", ".NETCoreApp,Version=v1.0");
}
示例8: BuildProject
protected CommandResult BuildProject(bool forceIncrementalUnsafe = false, bool expectBuildFailure = false)
{
var outputDir = GetBinDirectory();
var intermediateOutputDir = Path.Combine(Directory.GetParent(outputDir).FullName, "obj", _mainProject);
var mainProjectFile = GetProjectFile(_mainProject);
var buildCommand = new BuildCommand(mainProjectFile, output: outputDir, tempOutput: intermediateOutputDir ,forceIncrementalUnsafe : forceIncrementalUnsafe);
var result = buildCommand.ExecuteWithCapturedOutput();
if (!expectBuildFailure)
{
result.Should().Pass();
TestOutputExecutable(outputDir, buildCommand.GetOutputExecutableName(), _expectedOutput);
}
else
{
result.Should().Fail();
}
return result;
}
示例9: SatelliteAssemblyIsGeneratedByDotnetBuild
public void SatelliteAssemblyIsGeneratedByDotnetBuild()
{
// create unique directories in the 'temp' folder
var root = Temp.CreateDirectory();
var testLibDir = root.CreateDirectory("TestProjectWithCultureSpecificResource");
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestProjectWithCultureSpecificResource");
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
// run compile on a project with resources
var outputDir = Path.Combine(testLibDir.Path, "bin");
var testProject = GetProjectPath(testLibDir);
var buildCmd = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
var result = buildCmd.ExecuteWithCapturedOutput();
result.Should().Pass();
var generatedSatelliteAssemblyPath = Path.Combine(
outputDir,
"Debug",
DefaultFramework,
"fr",
"TestProjectWithCultureSpecificResource.resources.dll");
Assert.True(File.Exists(generatedSatelliteAssemblyPath), $"File {generatedSatelliteAssemblyPath} was not found.");
}
示例10: ContentFilesAreCopied
public void ContentFilesAreCopied()
{
var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithContentPackage")
.WithLockFiles();
var root = testInstance.TestRoot;
// run compile
var outputDir = Path.Combine(root, "bin");
var testProject = ProjectUtils.GetProjectJson(root, "TestAppWithContentPackage");
var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
var result = buildCommand.ExecuteWithCapturedOutput();
result.Should().Pass();
result = Command.Create(Path.Combine(outputDir, "AppWithContentPackage" + buildCommand.GetExecutableExtension()), new string [0])
.CaptureStdErr()
.CaptureStdOut()
.Execute();
result.Should().Pass();
// verify the output xml file
new DirectoryInfo(outputDir).Sub("scripts").Should()
.Exist()
.And.HaveFile("run.cmd");
new DirectoryInfo(outputDir).Should()
.HaveFile("config.xml");
// verify embedded resources
result.StdOut.Should().Contain("AppWithContentPackage.dnf.png");
result.StdOut.Should().Contain("AppWithContentPackage.ui.png");
// verify 'all' language files not included
result.StdOut.Should().NotContain("AppWithContentPackage.dnf_all.png");
result.StdOut.Should().NotContain("AppWithContentPackage.ui_all.png");
// verify classes
result.StdOut.Should().Contain("AppWithContentPackage.Foo");
result.StdOut.Should().Contain("MyNamespace.Util");
}
示例11: EmbeddedResourcesAreCopied
public void EmbeddedResourcesAreCopied()
{
var testInstance = TestAssetsManager.CreateTestInstance("EndToEndTestApp")
.WithLockFiles()
.WithBuildArtifacts();
var root = testInstance.TestRoot;
// run compile
var outputDir = Path.Combine(root, "bin");
var testProject = ProjectUtils.GetProjectJson(root, "EndToEndTestApp");
var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
var result = buildCommand.ExecuteWithCapturedOutput();
result.Should().Pass();
var objDirInfo = new DirectoryInfo(Path.Combine(root, "obj", "Debug", DefaultFramework));
objDirInfo.Should().HaveFile("EndToEndTestApp.resource1.resources");
objDirInfo.Should().HaveFile("myresource.resources");
objDirInfo.Should().HaveFile("EndToEndTestApp.defaultresource.resources");
}
示例12: CopyToOutputFilesAreCopied
public void CopyToOutputFilesAreCopied()
{
var testInstance = TestAssetsManager.CreateTestInstance("EndToEndTestApp")
.WithLockFiles()
.WithBuildArtifacts();
var root = testInstance.TestRoot;
// run compile
var outputDir = Path.Combine(root, "bin");
var testProject = ProjectUtils.GetProjectJson(root, "EndToEndTestApp");
var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultFramework);
var result = buildCommand.ExecuteWithCapturedOutput();
result.Should().Pass();
var outputDirInfo = new DirectoryInfo(Path.Combine(outputDir, "copy"));
outputDirInfo.Should().HaveFile("file.txt");
outputDirInfo.Should().NotHaveFile("fileex.txt");
}
示例13: MultipleFrameworks_ShouldHaveValidTargetFrameworkAttribute
public void MultipleFrameworks_ShouldHaveValidTargetFrameworkAttribute(string frameworkName, bool shouldHaveTargetFrameworkAttribute, bool windowsOnly)
{
var framework = NuGetFramework.Parse(frameworkName);
var testInstance = TestAssetsManager.CreateTestInstance("TestLibraryWithMultipleFrameworks")
.WithLockFiles();
var cmd = new BuildCommand(Path.Combine(testInstance.TestRoot, Project.FileName), framework: framework.GetShortFolderName());
if (windowsOnly && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// on non-windows platforms, desktop frameworks will not build
cmd.ExecuteWithCapturedOutput().Should().Fail();
}
else
{
cmd.ExecuteWithCapturedOutput().Should().Pass();
var output = Path.Combine(testInstance.TestRoot, "bin", "Debug", framework.GetShortFolderName(), "TestLibraryWithMultipleFrameworks.dll");
var targetFramework = PeReaderUtils.GetAssemblyAttributeValue(output, "TargetFrameworkAttribute");
if (shouldHaveTargetFrameworkAttribute)
{
targetFramework.Should().NotBeNull();
targetFramework.Should().BeEquivalentTo(framework.DotNetFrameworkName);
}
else
{
targetFramework.Should().BeNull();
}
}
}
示例14: SettingVersionSuffixFlag_ShouldStampAssemblyInfoInOutputAssembly
public void SettingVersionSuffixFlag_ShouldStampAssemblyInfoInOutputAssembly()
{
var testInstance = TestAssetsManager.CreateTestInstance("TestLibraryWithConfiguration")
.WithLockFiles();
var cmd = new BuildCommand(Path.Combine(testInstance.TestRoot, Project.FileName), framework: DefaultFramework, versionSuffix: "85");
cmd.ExecuteWithCapturedOutput().Should().Pass();
var output = Path.Combine(testInstance.TestRoot, "bin", "Debug", DefaultFramework, "TestLibraryWithConfiguration.dll");
var informationalVersion = PeReaderUtils.GetAssemblyAttributeValue(output, "AssemblyInformationalVersionAttribute");
informationalVersion.Should().NotBeNull();
informationalVersion.Should().BeEquivalentTo("1.0.0-85");
}
示例15: CanSetOutputAssemblyNameForLibraries
public void CanSetOutputAssemblyNameForLibraries()
{
var testInstance =
TestAssetsManager
.CreateTestInstance("LibraryWithOutputAssemblyName")
.WithLockFiles();
var root = testInstance.TestRoot;
var outputDir = Path.Combine(root, "bin");
var testProject = ProjectUtils.GetProjectJson(root, "LibraryWithOutputAssemblyName");
var buildCommand = new BuildCommand(testProject, output: outputDir, framework: DefaultLibraryFramework);
var result = buildCommand.ExecuteWithCapturedOutput();
result.Should().Pass();
new DirectoryInfo(outputDir).Should().HaveFiles(new [] { "MyLibrary.dll" });
}