Пример #1
0
 private int RunBuild(MSBuildRuntimeInfo runtime, string project, string msbuildArgs)
 {
     return(runtime.Type switch
     {
         MSBuildRuntimeType.Full => RunMSBuild(runtime.Version, project, msbuildArgs),
         MSBuildRuntimeType.Core => RunDotnetBuild(runtime.Version, project, msbuildArgs),
         _ => throw new NotImplementedException()
     });
Пример #2
0
        public void Documentation_is_generated_during_build(MSBuildRuntimeInfo runtime, string msbuildArgs, string[] expectedFiles)
        {
            // ARRANGE
            var packageFilePath = Directory.GetFiles("packages", "*.nupkg").Single();
            var packageId       = ExtractNuGetPackage(packageFilePath);

            CreateFile("Class1.cs",
                       @"
                namespace MyNamespace
                {
                    public class Class1
                    {
                    }
                }
                ");

            CreateFile("myproject.csproj",
                       $@"<Project Sdk=""Microsoft.NET.Sdk"">

                    <Import Project=""$(MSBuildThisFileDirectory)\\{packageId}\\build\\{packageId}.props"" />

                    <PropertyGroup>
                        <TargetFramework>netstandard2.0</TargetFramework>
                        <IsPackable>false</IsPackable>
                        <ApiReferenceDocumentationOutputPath>api/</ApiReferenceDocumentationOutputPath>
                        <CommandLineDocumentationOutputPath>commandlinehelp/</CommandLineDocumentationOutputPath>
                    </PropertyGroup>

                    <Import Project=""$(MSBuildThisFileDirectory)\\{packageId}\\build\\{packageId}.targets"" />

                </Project>");

            // ACT
            var exitCode = RunBuild(runtime, "myproject.csproj", msbuildArgs);

            // ASSERT
            Assert.Equal(0, exitCode);
            foreach (var file in expectedFiles)
            {
                Assert.True(File.Exists(Path.Combine(m_WorkingDirectory, file)));
            }
        }