コード例 #1
0
ファイル: Generator.cs プロジェクト: robertjebakumar/dotnet
        private string GenerateProjectForLocalBuild(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger) => $@"
<Project>
  <Import Project=""$(MSBuildSDKsPath)\Microsoft.NET.Sdk\Sdk\Sdk.props"" />
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>{TargetFrameworkMoniker}</TargetFramework>
    <RuntimeIdentifier>{runtimeIdentifier}</RuntimeIdentifier>
    <RuntimeFrameworkVersion>{RuntimeFrameworkVersion}</RuntimeFrameworkVersion>
    <AssemblyName>{artifactsPaths.ProgramName}</AssemblyName>
    <AssemblyTitle>{artifactsPaths.ProgramName}</AssemblyTitle>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
    <DebugType>pdbonly</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>
  <Import Project=""$(MSBuildSDKsPath)\Microsoft.NET.Sdk\Sdk\Sdk.targets"" />
  <Import Project=""$(IlcPath)\build\Microsoft.NETCore.Native.targets"" />
  {GetRuntimeSettings(buildPartition.RepresentativeBenchmark.Job.Env.Gc, buildPartition.Resolver)}
  <ItemGroup>
    <Compile Include=""{Path.GetFileName(artifactsPaths.ProgramCodePath)}"" Exclude=""bin\**;obj\**;**\*.xproj;packages\**"" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include=""{GetProjectFilePath(buildPartition.RepresentativeBenchmark.Target.Type, logger).FullName}"" />
  </ItemGroup>
</Project>";
コード例 #2
0
        /// <summary>
        /// mandatory to make it possible to call GC.GetAllocatedBytesForCurrentThread() using reflection (not part of .NET Standard)
        /// </summary>
        private void GenerateReflectionFile(ArtifactsPaths artifactsPaths)
        {
            const string content = @"
<Directives>
    <Application>
        <Assembly Name=""System.Runtime"">
            <Type Name=""System.GC"" Dynamic=""Required All"" />
        </Assembly>
        <Assembly Name=""System.Threading.ThreadPool"">
            <Type Name=""System.Threading.ThreadPool"" Dynamic=""Required All"" />
        </Assembly>
        <Assembly Name=""System.Threading"">
            <Type Name=""System.Threading.Monitor"" Dynamic=""Required All"" />
        </Assembly>
    </Application>
</Directives>
";

            string directoryName = Path.GetDirectoryName(artifactsPaths.ProjectFilePath);

            if (directoryName != null)
            {
                File.WriteAllText(Path.Combine(directoryName, "rd.xml"), content);
            }
            else
            {
                throw new InvalidOperationException($"Can't get directory of projectFilePath ('{artifactsPaths.ProjectFilePath}')");
            }
        }
コード例 #3
0
        protected override void GenerateBuildScript(Benchmark benchmark, ArtifactsPaths artifactsPaths, IResolver resolver)
        {
            string content = $"call dotnet {Builder.RestoreCommand} {GetCustomArguments(benchmark, resolver)}{Environment.NewLine}" +
                             $"call dotnet {Builder.GetBuildCommand(TargetFrameworkMoniker, false, benchmark.Job.ResolveValue(InfrastructureMode.BuildConfigurationCharacteristic, resolver))} {GetCustomArguments(benchmark, resolver)}";

            File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
        }
コード例 #4
0
        protected override void GenerateBuildScript(Benchmark benchmark, ArtifactsPaths artifactsPaths, IResolver resolver)
        {
            var prefix = RuntimeInformation.IsWindows() ? "" : "#!/bin/bash\n";
            var list   = new List <string>();

            if (!RuntimeInformation.IsWindows())
            {
                list.Add("mono");
            }
            list.Add("csc");
            list.Add("/noconfig");
            list.Add("/target:exe");
            list.Add("/optimize");
            list.Add("/unsafe");
            list.Add("/platform:" + benchmark.Job.Env.Platform.Resolve(resolver).ToConfig());
            list.Add("/appconfig:" + artifactsPaths.AppConfigPath.Escape());
            var references = GetAllReferences(benchmark).Select(assembly => assembly.Location.Escape());

            list.Add("/reference:" + string.Join(",", references));
            list.Add(Path.GetFileName(artifactsPaths.ProgramCodePath));

            File.WriteAllText(
                artifactsPaths.BuildScriptFilePath,
                prefix + string.Join(" ", list));
        }
コード例 #5
0
 protected override void CopyAllRequiredFiles(Benchmark benchmark, ArtifactsPaths artifactsPaths)
 {
     if (!Directory.Exists(artifactsPaths.BinariesDirectoryPath))
     {
         Directory.CreateDirectory(artifactsPaths.BinariesDirectoryPath);
     }
 }
コード例 #6
0
        protected void GenerateProjectInterpreter(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger)
        {
            BenchmarkCase benchmark   = buildPartition.RepresentativeBenchmarkCase;
            var           projectFile = GetProjectFilePath(benchmark.Descriptor.Type, logger);

            using (var file = new StreamReader(File.OpenRead(projectFile.FullName)))
            {
                var(customProperties, sdkName) = GetSettingsThatNeedsToBeCopied(file, projectFile);

                string content = new StringBuilder(ResourceHelper.LoadTemplate("WasmCsProj.txt"))
                                 .Replace("$PLATFORM$", buildPartition.Platform.ToConfig())
                                 .Replace("$CODEFILENAME$", Path.GetFileName(artifactsPaths.ProgramCodePath))
                                 .Replace("$CSPROJPATH$", projectFile.FullName)
                                 .Replace("$TFM$", TargetFrameworkMoniker)
                                 .Replace("$PROGRAMNAME$", artifactsPaths.ProgramName)
                                 .Replace("$COPIEDSETTINGS$", customProperties)
                                 .Replace("$CONFIGURATIONNAME$", buildPartition.BuildConfiguration)
                                 .Replace("$SDKNAME$", sdkName)
                                 .Replace("$RUNTIMEPACK$", CustomRuntimePack ?? "")
                                 .Replace("$TARGET$", CustomRuntimePack != null ? "PublishWithCustomRuntimePack" : "Publish")
                                 .ToString();

                File.WriteAllText(artifactsPaths.ProjectFilePath, content);
            }
        }
コード例 #7
0
        protected override void Cleanup(ArtifactsPaths artifactsPaths)
        {
            if (!Directory.Exists(artifactsPaths.BuildArtifactsDirectoryPath))
            {
                return;
            }

            int attempt = 0;

            while (true)
            {
                try
                {
                    Directory.Delete(artifactsPaths.BuildArtifactsDirectoryPath, recursive: true);
                    return;
                }
                catch (DirectoryNotFoundException) // it's crazy but it happens ;)
                {
                    return;
                }
                catch (Exception) when(attempt++ < 5)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(500)); // Previous benchmark run didn't release some files
                }
            }
        }
コード例 #8
0
ファイル: Generator.cs プロジェクト: kayle/BenchmarkDotNet
        private string GenerateProjectForNuGetBuild(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger) => $@"
<Project ToolsVersion=""15.0"">
  <PropertyGroup>
    <ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
    <ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
  </PropertyGroup>

  <Import Project=""Sdk.props"" Sdk=""Microsoft.NET.Sdk"" />

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>{TargetFrameworkMoniker}</TargetFramework>
    <RuntimeIdentifier>{runtimeIdentifier}</RuntimeIdentifier>
    <RuntimeFrameworkVersion>{RuntimeFrameworkVersion}</RuntimeFrameworkVersion>
    <AssemblyName>{artifactsPaths.ProgramName}</AssemblyName>
    <AssemblyTitle>{artifactsPaths.ProgramName}</AssemblyTitle>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
    <DebugType>pdbonly</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <UseSharedCompilation>false</UseSharedCompilation>
  </PropertyGroup>
  {GetRuntimeSettings(buildPartition.RepresentativeBenchmarkCase.Job.Environment.Gc, buildPartition.Resolver)}
  <ItemGroup>
    <Compile Include=""{Path.GetFileName(artifactsPaths.ProgramCodePath)}"" Exclude=""bin\**;obj\**;**\*.xproj;packages\**"" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include=""Microsoft.DotNet.ILCompiler"" Version=""{coreRtVersion}"" />
    <ProjectReference Include=""{GetProjectFilePath(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).FullName}"" />
  </ItemGroup>
  <Import Project=""Sdk.targets"" Sdk=""Microsoft.NET.Sdk"" />
</Project>";
コード例 #9
0
        protected override void GenerateProject(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger)
        {
            BenchmarkCase benchmark   = buildPartition.RepresentativeBenchmarkCase;
            var           projectFile = GetProjectFilePath(benchmark.Descriptor.Type, logger);

            string useLLVM = AotCompilerMode == MonoAotCompilerMode.llvm ? "true" : "false";

            using (var file = new StreamReader(File.OpenRead(projectFile.FullName)))
            {
                var(customProperties, sdkName) = GetSettingsThatNeedsToBeCopied(file, projectFile);

                string content = new StringBuilder(ResourceHelper.LoadTemplate("MonoAOTLLVMCsProj.txt"))
                                 .Replace("$PLATFORM$", buildPartition.Platform.ToConfig())
                                 .Replace("$CODEFILENAME$", Path.GetFileName(artifactsPaths.ProgramCodePath))
                                 .Replace("$CSPROJPATH$", projectFile.FullName)
                                 .Replace("$TFM$", TargetFrameworkMoniker)
                                 .Replace("$PROGRAMNAME$", artifactsPaths.ProgramName)
                                 .Replace("$COPIEDSETTINGS$", customProperties)
                                 .Replace("$CONFIGURATIONNAME$", buildPartition.BuildConfiguration)
                                 .Replace("$SDKNAME$", sdkName)
                                 .Replace("$RUNTIMEPACK$", CustomRuntimePack ?? "")
                                 .Replace("$COMPILERBINARYPATH$", AotCompilerPath)
                                 .Replace("$RUNTIMEIDENTIFIER$", CustomDotNetCliToolchainBuilder.GetPortableRuntimeIdentifier())
                                 .Replace("$USELLVM$", useLLVM)
                                 .ToString();

                File.WriteAllText(artifactsPaths.ProjectFilePath, content);
            }
        }
コード例 #10
0
        protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths artifactsPaths, IResolver resolver, ILogger logger)
        {
            string csProj = $@"
<Project Sdk=""Microsoft.NET.Sdk"">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>{TargetFrameworkMoniker}</TargetFramework>
    <RuntimeIdentifier>{RuntimeIdentifier}</RuntimeIdentifier>
    <AssemblyName>{artifactsPaths.ProgramName}</AssemblyName>
    <AssemblyTitle>{artifactsPaths.ProgramName}</AssemblyTitle>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
    <DebugType>pdbonly</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <PackageConflictPreferredPackages>Microsoft.Private.CoreFx.NETCoreApp;runtime.{RuntimeIdentifier}.Microsoft.Private.CoreFx.NETCoreApp;Microsoft.NETCore.App;$(PackageConflictPreferredPackages)</PackageConflictPreferredPackages>
  </PropertyGroup>
  {GetRuntimeSettings(benchmark.Job.Env.Gc, resolver)}
  <ItemGroup>
    <Compile Include=""{Path.GetFileName(artifactsPaths.ProgramCodePath)}"" Exclude=""bin\**;obj\**;**\*.xproj;packages\**"" />
  </ItemGroup>
  <ItemGroup>
    {string.Join(Environment.NewLine, GetReferences(benchmark, logger))}
  </ItemGroup>
</Project>";

            File.WriteAllText(artifactsPaths.ProjectFilePath, csProj);
        }
コード例 #11
0
        protected override void GenerateBuildScript(BuildPartition buildPartition, ArtifactsPaths artifactsPaths)
        {
            string content = $"call dotnet {Builder.RestoreCommand} {GetCustomArguments(buildPartition.RepresentativeBenchmark, buildPartition.Resolver)}{Environment.NewLine}" +
                             $"call dotnet {Builder.GetBuildCommand(TargetFrameworkMoniker, false, buildPartition.BuildConfiguration)} {GetCustomArguments(buildPartition.RepresentativeBenchmark, buildPartition.Resolver)}";

            File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
        }
コード例 #12
0
        protected override void Cleanup(ArtifactsPaths artifactsPaths)
        {
            if (!Directory.Exists(artifactsPaths.BuildArtifactsDirectoryPath))
            {
                return;
            }

            int attempt = 0;
            while (true)
            {
                try
                {
                    Directory.Delete(artifactsPaths.BuildArtifactsDirectoryPath, recursive: true);
                    return;
                }
                catch (DirectoryNotFoundException) // it's crazy but it happens ;)
                {
                    return;
                }
                catch (Exception) when (attempt++ < 5)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(500)); // Previous benchmark run didn't release some files
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// update CoreRun folder with newer versions of duplicated dependencies
        /// </summary>
        private void UpdateDuplicatedDependencies(ArtifactsPaths artifactsPaths, ILogger logger)
        {
            var publishedDirectory = new DirectoryInfo(artifactsPaths.BinariesDirectoryPath);
            var coreRunDirectory   = CoreRun.Directory;

            foreach (var publishedDependency in publishedDirectory
                     .EnumerateFileSystemInfos()
                     .Where(file => file.Extension == ".dll" || file.Extension == ".exe"))
            {
                var coreRunDependency = new FileInfo(Path.Combine(coreRunDirectory.FullName, publishedDependency.Name));

                if (!coreRunDependency.Exists)
                {
                    continue; // the file does not exist in CoreRun directory, we don't need to worry, it will be just loaded from publish directory by CoreRun
                }
                var publishedVersionInfo = FileVersionInfo.GetVersionInfo(publishedDependency.FullName);
                var coreRunVersionInfo   = FileVersionInfo.GetVersionInfo(coreRunDependency.FullName);

                if (!Version.TryParse(publishedVersionInfo.FileVersion, out var publishedVersion) || !Version.TryParse(coreRunVersionInfo.FileVersion, out var coreRunVersion))
                {
                    continue;
                }

                if (publishedVersion > coreRunVersion)
                {
                    File.Copy(publishedDependency.FullName, coreRunDependency.FullName, overwrite: true); // we need to ovwerite old things with their newer versions

                    logger.WriteLineInfo($"Copying {publishedDependency.FullName} to {coreRunDependency.FullName}");
                }
            }
        }
コード例 #14
0
 protected override void Cleanup(ArtifactsPaths artifactsPaths)
 {
     DelteIfExists(artifactsPaths.ProgramCodePath);
     DelteIfExists(artifactsPaths.AppConfigPath);
     DelteIfExists(artifactsPaths.BuildScriptFilePath);
     DelteIfExists(artifactsPaths.ExecutablePath);
 }
コード例 #15
0
 public GenerateResult(ArtifactsPaths artifactsPaths, bool isGenerateSuccess, Exception generateException, IReadOnlyCollection <string> artifactsToCleanup)
 {
     ArtifactsPaths     = artifactsPaths;
     IsGenerateSuccess  = isGenerateSuccess;
     GenerateException  = generateException;
     ArtifactsToCleanup = artifactsToCleanup;
 }
コード例 #16
0
        private string GenerateProjectForLocalBuild(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger) => $@"
<Project>
  <Import Project=""$(MSBuildSDKsPath)\Microsoft.NET.Sdk\Sdk\Sdk.props"" />
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>{TargetFrameworkMoniker}</TargetFramework>
    <RuntimeIdentifier>{runtimeIdentifier}</RuntimeIdentifier>
    <RuntimeFrameworkVersion>{RuntimeFrameworkVersion}</RuntimeFrameworkVersion>
    <AssemblyName>{artifactsPaths.ProgramName}</AssemblyName>
    <AssemblyTitle>{artifactsPaths.ProgramName}</AssemblyTitle>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
    <DebugType>pdbonly</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <UseSharedCompilation>false</UseSharedCompilation>
    <Deterministic>true</Deterministic>
    <RootAllApplicationAssemblies>{rootAllApplicationAssemblies}</RootAllApplicationAssemblies>
    <IlcGenerateCompleteTypeMetadata>{ilcGenerateCompleteTypeMetadata}</IlcGenerateCompleteTypeMetadata>
    <IlcGenerateStackTraceData>{ilcGenerateStackTraceData}</IlcGenerateStackTraceData>
  </PropertyGroup>
  <Import Project=""$(MSBuildSDKsPath)\Microsoft.NET.Sdk\Sdk\Sdk.targets"" />
  <Import Project=""$(IlcPath)\build\Microsoft.NETCore.Native.targets"" />
  {GetRuntimeSettings(buildPartition.RepresentativeBenchmarkCase.Job.Environment.Gc, buildPartition.Resolver)}
  <ItemGroup>
    <Compile Include=""{Path.GetFileName(artifactsPaths.ProgramCodePath)}"" Exclude=""bin\**;obj\**;**\*.xproj;packages\**"" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include=""{GetProjectFilePath(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).FullName}"" />
  </ItemGroup>
  <ItemGroup>
    <RdXmlFile Include=""rd.xml"" />
  </ItemGroup>
</Project>";
コード例 #17
0
        protected override void GenerateBuildScript(Benchmark benchmark, ArtifactsPaths artifactsPaths)
        {
            var content = $"call dotnet {DotNetCliBuilder.RestoreCommand}{Environment.NewLine}" +
                          $"call dotnet {DotNetCliBuilder.GetBuildCommand(TargetFrameworkMoniker)}";

            File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
        }
コード例 #18
0
 protected override void Cleanup(ArtifactsPaths artifactsPaths)
 {
     DelteIfExists(artifactsPaths.ProgramCodePath);
     DelteIfExists(artifactsPaths.AppConfigPath);
     DelteIfExists(artifactsPaths.BuildScriptFilePath);
     DelteIfExists(artifactsPaths.ExecutablePath);
 }
コード例 #19
0
        protected override void GenerateBuildScript(Benchmark benchmark, ArtifactsPaths artifactsPaths, IResolver resolver)
        {
            string content = $"call dotnet {Builder.RestoreCommand}{Environment.NewLine}" +
                             $"call dotnet {Builder.GetBuildCommand(TargetFrameworkMoniker, justTheProjectItself: false)}";

            File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
        }
コード例 #20
0
        private string GenerateProjectForNuGetBuild(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger) => $@"
<Project Sdk=""Microsoft.NET.Sdk"">
  <PropertyGroup>
    <ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
    <ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
    <OutputType>Exe</OutputType>
    <TargetFramework>{TargetFrameworkMoniker}</TargetFramework>
    <RuntimeIdentifier>{runtimeIdentifier}</RuntimeIdentifier>
    <RuntimeFrameworkVersion>{RuntimeFrameworkVersion}</RuntimeFrameworkVersion>
    <AssemblyName>{artifactsPaths.ProgramName}</AssemblyName>
    <AssemblyTitle>{artifactsPaths.ProgramName}</AssemblyTitle>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
    <DebugType>pdbonly</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <UseSharedCompilation>false</UseSharedCompilation>
    <Deterministic>true</Deterministic>
    {GetTrimmingSettings()}
    <IlcGenerateCompleteTypeMetadata>{ilcGenerateCompleteTypeMetadata}</IlcGenerateCompleteTypeMetadata>
    <IlcGenerateStackTraceData>{ilcGenerateStackTraceData}</IlcGenerateStackTraceData>
    <EnsureNETCoreAppRuntime>false</EnsureNETCoreAppRuntime> <!-- workaround for 'This runtime may not be supported by.NET Core.' error -->
  </PropertyGroup>
  {GetRuntimeSettings(buildPartition.RepresentativeBenchmarkCase.Job.Environment.Gc, buildPartition.Resolver)}
  <ItemGroup>
    <Compile Include=""{Path.GetFileName(artifactsPaths.ProgramCodePath)}"" Exclude=""bin\**;obj\**;**\*.xproj;packages\**"" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include=""Microsoft.DotNet.ILCompiler"" Version=""{coreRtVersion}"" />
    <ProjectReference Include=""{GetProjectFilePath(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).FullName}"" />
  </ItemGroup>
  <ItemGroup>
    <RdXmlFile Include=""rd.xml"" />
  </ItemGroup>
</Project>";
コード例 #21
0
 internal static string GetRestoreCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string extraArguments = null)
 => new StringBuilder(100)
 .Append("restore ")
 .Append(string.IsNullOrEmpty(artifactsPaths.PackagesDirectoryName) ? string.Empty : $"--packages \"{artifactsPaths.PackagesDirectoryName}\" ")
 .Append(GetCustomMsBuildArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver))
 .Append(extraArguments)
 .Append(MandatoryUseSharedCompilationFalse)
 .ToString();
コード例 #22
0
 protected override string[] GetArtifactsToCleanup(ArtifactsPaths artifactsPaths)
 => new[]
 {
     artifactsPaths.ProgramCodePath,
     artifactsPaths.AppConfigPath,
     artifactsPaths.BuildScriptFilePath,
     artifactsPaths.ExecutablePath
 };
コード例 #23
0
 internal static string GetPublishCommand(ArtifactsPaths artifactsPaths, BuildPartition buildPartition, string extraArguments = null)
 => new StringBuilder()
 .Append($"publish -c {buildPartition.BuildConfiguration} ")         // we don't need to specify TFM, our auto-generated project contains always single one
 .Append(GetCustomMsBuildArguments(buildPartition.RepresentativeBenchmarkCase, buildPartition.Resolver))
 .Append(extraArguments)
 .Append(GetMandatoryMsBuildSettings(buildPartition.BuildConfiguration))
 .Append(string.IsNullOrEmpty(artifactsPaths.PackagesDirectoryName) ? string.Empty : $" /p:NuGetPackageRoot=\"{artifactsPaths.PackagesDirectoryName}\"")
 .ToString();
コード例 #24
0
        protected override void GenerateProject(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger)
        {
            File.WriteAllText(artifactsPaths.ProjectFilePath,
                              IsNuGetCoreRt
                    ? GenerateProjectForNuGetBuild(buildPartition, artifactsPaths, logger)
                    : GenerateProjectForLocalBuild(buildPartition, artifactsPaths, logger));

            GenerateReflectionFile(artifactsPaths);
        }
コード例 #25
0
        protected override void GenerateBuildScript(BuildPartition buildPartition, ArtifactsPaths artifactsPaths)
        {
            var content = new StringBuilder(300)
                          .AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetRestoreCommand(artifactsPaths, buildPartition)}")
                          .AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetBuildCommand(buildPartition)}")
                          .ToString();

            File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
        }
コード例 #26
0
        protected override void CopyAllRequiredFiles(ArtifactsPaths artifactsPaths)
        {
            if (NeedsCopy)
            {
                CopyFilesRecursively(SourceCoreRun.Directory, CopyCoreRun.Directory);
            }

            base.CopyAllRequiredFiles(artifactsPaths);
        }
コード例 #27
0
 protected override void GenerateProject(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger)
 {
     if (((WasmRuntime)buildPartition.Runtime).Aot)
     {
         GenerateProjectAot(buildPartition, artifactsPaths, logger);
     }
     else
     {
         GenerateProjectInterpreter(buildPartition, artifactsPaths, logger);
     }
 }
コード例 #28
0
ファイル: Generator.cs プロジェクト: dotnet/BenchmarkDotNet
        protected override void GenerateBuildScript(BuildPartition buildPartition, ArtifactsPaths artifactsPaths)
        {
            string extraArguments = NativeAotToolchain.GetExtraArguments(runtimeIdentifier);

            var content = new StringBuilder(300)
                          .AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetRestoreCommand(artifactsPaths, buildPartition, extraArguments)}")
                          .AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetBuildCommand(artifactsPaths, buildPartition, extraArguments)}")
                          .AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetPublishCommand(artifactsPaths, buildPartition, extraArguments)}")
                          .ToString();

            File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
        }
コード例 #29
0
        protected override void GenerateBuildScript(BuildPartition buildPartition, ArtifactsPaths artifactsPaths)
        {
            string extraArguments = useCppCodeGenerator ? $"-r {runtimeIdentifier} /p:NativeCodeGen=cpp" : $"-r {runtimeIdentifier}";

            var content = new StringBuilder(300)
                          .AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetRestoreCommand(artifactsPaths, buildPartition)} {extraArguments}")
                          .AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetBuildCommand(artifactsPaths, buildPartition)} {extraArguments}")
                          .AppendLine($"call {CliPath ?? "dotnet"} {DotNetCliCommand.GetPublishCommand(artifactsPaths, buildPartition)} {extraArguments}")
                          .ToString();

            File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
        }
コード例 #30
0
 public ExternalProcessGenerator(string exePath)
 {
     _artifactsPaths = new ArtifactsPaths(
         rootArtifactsFolderPath: "",
         buildArtifactsDirectoryPath: "",
         binariesDirectoryPath: "",
         programCodePath: "",
         appConfigPath: "",
         projectFilePath: "",
         buildScriptFilePath: "",
         executablePath: exePath,
         programName: Path.GetFileName(exePath));
 }
コード例 #31
0
        protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths artifactsPaths, IResolver resolver)
        {
            string template = ResourceHelper.LoadTemplate("CsProj.txt");

            string content = SetPlatform(template, PlatformProvider(benchmark.Job.ResolveValue(EnvMode.PlatformCharacteristic, resolver)));

            content = SetCodeFileName(content, Path.GetFileName(artifactsPaths.ProgramCodePath));
            content = SetDependencyToExecutingAssembly(content, benchmark.Target.Type);
            content = SetTargetFrameworkMoniker(content, TargetFrameworkMoniker);
            //content = SetGcMode(content, benchmark.Job.Env.Gc, resolver); todo: implement

            File.WriteAllText(artifactsPaths.ProjectFilePath, content);
        }
コード例 #32
0
        protected override void GenerateNuGetConfig(ArtifactsPaths artifactsPaths)
        {
            string content =
                $@"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <packageSources>
    {(useNuGetClearTag ? "<clear/>" : string.Empty)}
    {string.Join(Environment.NewLine + "    ", feeds.Select(feed => $"<add key=\"{feed.Key}\" value=\"{feed.Value}\" />"))}
  </packageSources>
</configuration>";

            File.WriteAllText(artifactsPaths.NuGetConfigPath, content);
        }
コード例 #33
0
        protected override void GenerateBuildScript(Benchmark benchmark, ArtifactsPaths artifactsPaths, IResolver resolver)
        {
            var prefix = RuntimeInformation.IsWindows() ? "" : "#!/bin/bash\n";
            var list = new List<string>();
            if (!RuntimeInformation.IsWindows())
                list.Add("mono");
            list.Add("csc");
            list.Add("/noconfig");
            list.Add("/target:exe");
            list.Add("/optimize");
            list.Add("/unsafe");
            list.Add("/platform:" + benchmark.Job.ResolveValue(EnvMode.PlatformCharacteristic, resolver).ToConfig());
            list.Add("/appconfig:" + artifactsPaths.AppConfigPath.Escape());
            var references = GetAllReferences(benchmark).Select(assembly => assembly.Location.Escape());
            list.Add("/reference:" + string.Join(",", references));
            list.Add(Path.GetFileName(artifactsPaths.ProgramCodePath));

            File.WriteAllText(
                artifactsPaths.BuildScriptFilePath,
                prefix + string.Join(" ", list));
        }
コード例 #34
0
        protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths artifactsPaths)
        {
            var template = ResourceHelper.LoadTemplate("BenchmarkProject.json");

            var content = SetPlatform(template, PlatformProvider(benchmark.Job.Platform));
            content = SetCodeFileName(content, Path.GetFileName(artifactsPaths.ProgramCodePath));
            content = SetDependencyToExecutingAssembly(content, benchmark.Target.Type);
            content = SetTargetFrameworkMoniker(content, TargetFrameworkMoniker);
            content = SetExtraDependencies(content, ExtraDependencies);
            content = SetImports(content, Imports);
            content = SetRuntime(content, Runtime);
            content = SetGarbageCollectionSettings(content, benchmark.Job.GarbageCollection);

            File.WriteAllText(artifactsPaths.ProjectFilePath, content);
        }
コード例 #35
0
 public static GenerateResult Failure(ArtifactsPaths artifactsPaths, Exception exception = null) => new GenerateResult(artifactsPaths, false, exception);
コード例 #36
0
        protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths artifactsPaths, IResolver resolver)
        {
            string template = ResourceHelper.LoadTemplate("BenchmarkProject.json");

            string content = SetPlatform(template, PlatformProvider(benchmark.Job.ResolveValue(EnvMode.PlatformCharacteristic, resolver)));
            content = SetCodeFileName(content, Path.GetFileName(artifactsPaths.ProgramCodePath));
            content = SetDependencyToExecutingAssembly(content, benchmark.Target.Type);
            content = SetTargetFrameworkMoniker(content, TargetFrameworkMoniker);
            content = SetExtraDependencies(content, ExtraDependencies);
            content = SetImports(content, Imports);
            content = SetRuntime(content, Runtime);
            content = SetGcMode(content, benchmark.Job.Env.Gc, resolver);

            File.WriteAllText(artifactsPaths.ProjectFilePath, content);
        }
コード例 #37
0
 public static GenerateResult Success(ArtifactsPaths artifactsPaths) => new GenerateResult(artifactsPaths, true, null);
コード例 #38
0
 protected override void CopyAllRequiredFiles(ArtifactsPaths artifactsPaths)
 {
     if (!Directory.Exists(artifactsPaths.BinariesDirectoryPath))
     {
         Directory.CreateDirectory(artifactsPaths.BinariesDirectoryPath);
     }   
 }
コード例 #39
0
        protected override void GenerateBuildScript(Benchmark benchmark, ArtifactsPaths artifactsPaths)
        {
            var content = $"call dotnet {DotNetCliBuilder.RestoreCommand}{Environment.NewLine}" +
                          $"call dotnet {DotNetCliBuilder.GetBuildCommand(TargetFrameworkMoniker)}";

            File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
        }
コード例 #40
0
 public GenerateResult(ArtifactsPaths artifactsPaths, bool isGenerateSuccess, Exception generateException)
 {
     ArtifactsPaths = artifactsPaths;
     IsGenerateSuccess = isGenerateSuccess;
     GenerateException = generateException;
 }