private async Task <string> Publish(DotNetInstallation dotNetInstall, string outputDir, ITestOutputHelper output) { string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); string publishDir = GetWebAppPublishDirectory(dotNetInstall, outputDir, tfm); string manifestPath = Path.Combine(GetWebAppStoreDir(outputDir), dotNetInstall.Architecture, tfm, "artifact.xml"); if (publishDir != null) { FileTasks.DeleteDirectory(publishDir, output); } string dotNetExePath = dotNetInstall.DotNetExe; await new ProcessRunner(dotNetExePath, $"publish -c Release -f {tfm} --manifest {manifestPath}") .WithWorkingDirectory(GetWebAppSrcDirectory(outputDir)) .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .WithEnvironmentVariable("JITBENCH_ASPNET_VERSION", "2.0") .WithEnvironmentVariable("JITBENCH_TARGET_FRAMEWORK_MONIKER", tfm) .WithEnvironmentVariable("JITBENCH_FRAMEWORK_VERSION", dotNetInstall.FrameworkVersion) .WithEnvironmentVariable("UseSharedCompilation", "false") .WithLog(output) .Run(); publishDir = GetWebAppPublishDirectory(dotNetInstall, outputDir, tfm); if (publishDir == null) { throw new DirectoryNotFoundException("Could not find 'publish' directory"); } return(publishDir); }
private async Task <string> Publish(DotNetInstallation dotNetInstall, string outputDir, ITestOutputHelper output) { string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); string publishDir = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); if (publishDir != null) { FileTasks.DeleteDirectory(publishDir, output); } string dotNetExePath = dotNetInstall.DotNetExe; await new ProcessRunner(dotNetExePath, $"publish -c Release -f {tfm}") .WithWorkingDirectory(GetWord2VecNetSrcDirectory(outputDir)) .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .WithEnvironmentVariable("WORD2VEC_FRAMEWORK_VERSION", dotNetInstall.FrameworkVersion) .WithEnvironmentVariable("UseSharedCompilation", "false") .WithLog(output) .Run(); publishDir = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); if (publishDir == null) { throw new DirectoryNotFoundException($"Could not find 'publish' directory: {publishDir}"); } return(publishDir); }
public override async Task Setup(DotNetInstallation dotNetInstall, string intermediateOutputDir, bool useExistingSetup, ITestOutputHelper output) { using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output)) { await SetupHelloWorldProject(dotNetInstall, intermediateOutputDir, useExistingSetup, setupSection); } }
protected async Task SetupHelloWorldProject(DotNetInstallation dotNetInstall, string intermediateOutputDir, bool useExistingSetup, ITestOutputHelper output) { string helloWorldProjectDir = Path.Combine(intermediateOutputDir, "helloworld"); //the 'exePath' gets passed as an argument to dotnet.exe //in this case it isn't an executable at all, its a CLI command //a little cheap, but it works ExePath = "build"; WorkingDirPath = helloWorldProjectDir; // This disables using the shared build server. I was told using it interferes with the ability to delete folders after the // test is complete though I haven't encountered that particular issue myself. I imagine this meaningfully changes the // performance of this benchmark, so if we ever want to do real perf testing on the shared scenario we have to resolve this // issue another way. EnvironmentVariables["UseSharedCompilation"] = "false"; if (!useExistingSetup) { FileTasks.DeleteDirectory(helloWorldProjectDir, output); FileTasks.CreateDirectory(helloWorldProjectDir, output); await new ProcessRunner(dotNetInstall.DotNetExe, "new console") .WithWorkingDirectory(helloWorldProjectDir) .WithLog(output) .Run(); RetargetProjects(dotNetInstall, helloWorldProjectDir, new string[] { "helloworld.csproj" }); } }
public override async Task Setup(DotNetInstallation dotNetInstall, string intermediateOutputDir, bool useExistingSetup, ITestOutputHelper output) { using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output)) { SetupCscBinDir(dotNetInstall.SdkDir, dotNetInstall.FrameworkVersion, intermediateOutputDir, useExistingSetup, setupSection); await SetupSourceToCompile(intermediateOutputDir, dotNetInstall.FrameworkDir, useExistingSetup, setupSection); } }
async Task DownloadAndExtractTextCorpus(DotNetInstallation dotNetInstall, string outputDir, ITestOutputHelper output) { // If the file already exists, exit string word2VecNetRepoRootDir = GetWord2VecNetRepoRootDir(outputDir); string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); string word2VecNetPublishDir = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); // Download the corpus of text. This is a zip file that contains a text file of 100M of text from Wikipedia var url = "https://perfbenchmarkstorage.blob.core.windows.net/corpus/Corpus10.zip"; await FileTasks.DownloadAndUnzip(url, word2VecNetRepoRootDir + "_temp", output); FileTasks.MoveFile(Path.Combine(word2VecNetRepoRootDir + "_temp", "Corpus.txt"), Path.Combine(word2VecNetPublishDir, "Corpus.txt"), output); }
public override async Task Setup(DotNetInstallation dotNetInstall, string outputDir, bool useExistingSetup, ITestOutputHelper output) { if (!useExistingSetup) { using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output)) { await CloneWord2VecNetRepo(outputDir, setupSection); await Publish(dotNetInstall, outputDir, setupSection); await DownloadAndExtractTextCorpus(dotNetInstall, outputDir, setupSection); } } string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); WorkingDirPath = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); }
private async Task CreateStore(DotNetInstallation dotNetInstall, string outputDir, ITestOutputHelper output) { string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); string rid = $"win7-{dotNetInstall.Architecture}"; string storeDirName = ".store"; await new ProcessRunner("powershell.exe", $".\\AspNet-GenerateStore.ps1 -InstallDir {storeDirName} -Architecture {dotNetInstall.Architecture} -Runtime {rid}") .WithWorkingDirectory(GetJitBenchRepoRootDir(outputDir)) .WithEnvironmentVariable("PATH", $"{dotNetInstall.DotNetDir};{Environment.GetEnvironmentVariable("PATH")}") .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .WithEnvironmentVariable("JITBENCH_TARGET_FRAMEWORK_MONIKER", tfm) .WithEnvironmentVariable("JITBENCH_FRAMEWORK_VERSION", dotNetInstall.FrameworkVersion) .WithLog(output) .Run(); }
private async Task CreateStore(DotNetInstallation dotNetInstall, string outputDir, ITestOutputHelper output) { string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); string storeDirName = ".store"; await(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? new ProcessRunner("powershell.exe", $".\\AspNet-GenerateStore.ps1 -InstallDir {storeDirName} -Architecture {dotNetInstall.Architecture} -Runtime win7-{dotNetInstall.Architecture}") : new ProcessRunner("bash", $"./aspnet-generatestore.sh --install-dir {storeDirName} --architecture {dotNetInstall.Architecture} --runtime-id linux-{dotNetInstall.Architecture} -f {tfm} --fx-version {dotNetInstall.FrameworkVersion}")) .WithWorkingDirectory(GetJitBenchRepoRootDir(outputDir)) .WithEnvironmentVariable("PATH", $"{dotNetInstall.DotNetDir}{Path.PathSeparator}{Environment.GetEnvironmentVariable("PATH")}") .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") .WithEnvironmentVariable("JITBENCH_TARGET_FRAMEWORK_MONIKER", tfm) .WithEnvironmentVariable("JITBENCH_FRAMEWORK_VERSION", dotNetInstall.FrameworkVersion) .WithLog(output) .Run(); }
public override async Task Setup(DotNetInstallation dotNetInstall, string outputDir, bool useExistingSetup, ITestOutputHelper output) { if (!useExistingSetup) { using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output)) { await SetupSourceToCompile(outputDir, dotNetInstall.FrameworkDir, useExistingSetup, setupSection); await Publish(dotNetInstall, outputDir, setupSection); } } string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); WorkingDirPath = GetAppPublishDirectory(dotNetInstall, outputDir, tfm); EnvironmentVariables.Add("DOTNET_MULTILEVEL_LOOKUP", "0"); EnvironmentVariables.Add("UseSharedCompilation", "false"); }
public override async Task Setup(DotNetInstallation dotNetInstall, string outputDir, bool useExistingSetup, ITestOutputHelper output) { if (!useExistingSetup) { using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output)) { await CloneAspNetJitBenchRepo(outputDir, setupSection); await CreateStore(dotNetInstall, outputDir, setupSection); await Publish(dotNetInstall, outputDir, setupSection); } } string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); WorkingDirPath = GetWebAppPublishDirectory(dotNetInstall, outputDir, tfm); EnvironmentVariables.Add("DOTNET_SHARED_STORE", GetWebAppStoreDir(outputDir)); }
string GetWebAppPublishDirectory(DotNetInstallation dotNetInstall, string outputDir, string tfm) { string dir = Path.Combine(GetWebAppSrcDirectory(outputDir), "bin", dotNetInstall.Architecture, "Release", tfm, "publish"); if (Directory.Exists(dir)) { return(dir); } dir = Path.Combine(GetWebAppSrcDirectory(outputDir), "bin", "Release", tfm, "publish"); if (Directory.Exists(dir)) { return(dir); } return(null); }
async Task PrepareDotNet(ITestOutputHelper output) { if (!UseExistingSetup) { DotNetSetup setup = new DotNetSetup(Path.Combine(OutputDir, ".dotnet")) .WithSdkVersion(DotnetSdkVersion) .WithArchitecture(Architecture); if (DotnetFrameworkVersion != "use-sdk") { setup.WithFrameworkVersion(DotnetFrameworkVersion); } if (PrivateCoreCLRBinDir != null) { setup.WithPrivateRuntimeBinaryOverlay(PrivateCoreCLRBinDir); } DotNetInstallation = await setup.Run(output); } else { DotNetInstallation = new DotNetInstallation(Path.Combine(OutputDir, ".dotnet"), DotnetFrameworkVersion, DotnetSdkVersion, Architecture); } }
public override async Task Setup(DotNetInstallation dotNetInstall, string outputDir, bool useExistingSetup, ITestOutputHelper output) { if (!useExistingSetup) { using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output)) { await CloneWord2VecNetRepo(outputDir, setupSection); RetargetProjects( dotNetInstall, GetWord2VecNetRepoRootDir(outputDir), new string[] { Path.Combine("Word2Vec.Net", "Word2Vec.Net.csproj"), Path.Combine("Word2VecScenario", "Word2VecScenario.csproj") }); await Publish(dotNetInstall, outputDir, setupSection); await DownloadAndExtractTextCorpus(dotNetInstall, outputDir, setupSection); } } string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); WorkingDirPath = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); }
async public Task <DotNetInstallation> Run(ITestOutputHelper output) { using (var acquireOutput = new IndentedTestOutputHelper("Acquiring DotNet", output)) { string remoteSdkPath = GetSDKDownloadLink(); if (remoteSdkPath != null) { await FileTasks.DownloadAndUnzip(remoteSdkPath, DotNetDirPath, acquireOutput); } string remoteRuntimePath = GetFrameworkDownloadLink(); if (remoteRuntimePath != null) { await FileTasks.DownloadAndUnzip(remoteRuntimePath, DotNetDirPath, acquireOutput); // the SDK may have included another runtime version, but to help prevent mistakes // where a test might run against a different version than we intended all other // versions will be deleted. string mnappDirPath = Path.Combine(DotNetDirPath, "shared", "Microsoft.NETCore.App"); foreach (string dir in Directory.GetDirectories(mnappDirPath)) { string versionDir = Path.GetFileName(dir); if (versionDir != FrameworkVersion) { FileTasks.DeleteDirectory(dir, acquireOutput); } } } string actualFrameworkVersion = FrameworkVersion; if (actualFrameworkVersion == null) { //if Framework version is being infered from an SDK then snoop the filesystem to see what got installed foreach (string dirPath in Directory.EnumerateDirectories(Path.Combine(DotNetDirPath, "shared", "Microsoft.NETCore.App"))) { actualFrameworkVersion = Path.GetFileName(dirPath); break; } } DotNetInstallation result = new DotNetInstallation(DotNetDirPath, actualFrameworkVersion, SdkVersion, Architecture); acquireOutput.WriteLine("Dotnet path: " + result.DotNetExe); if (!File.Exists(result.DotNetExe)) { throw new FileNotFoundException(result.DotNetExe + " not found"); } if (result.SdkVersion != null) { if (!Directory.Exists(result.SdkDir)) { throw new DirectoryNotFoundException("Sdk directory " + result.SdkDir + " not found"); } } if (result.FrameworkVersion != null) { if (!Directory.Exists(result.FrameworkDir)) { throw new DirectoryNotFoundException("Framework directory " + result.FrameworkDir + " not found"); } //overlay private binaries if needed if (PrivateRuntimeBinaryDirPath != null) { foreach (string fileName in GetPrivateRuntimeOverlayBinaryNames(OS)) { string backupPath = Path.Combine(result.FrameworkDir, fileName + ".original"); string overwritePath = Path.Combine(result.FrameworkDir, fileName); string privateBinPath = Path.Combine(PrivateRuntimeBinaryDirPath, fileName); if (!File.Exists(backupPath)) { File.Copy(overwritePath, backupPath); } if (!File.Exists(privateBinPath)) { throw new FileNotFoundException("Private binary " + privateBinPath + " not found"); } File.Copy(privateBinPath, overwritePath, true); } } } return(result); } }
public static string GetSDKDownloadLink(string azureFeed, string version, OSPlatform os, Architecture arch) { return(GetSDKDownloadLink(azureFeed, version, GetNormalizedOSName(os), DotNetInstallation.GetNormalizedArchitectureName(arch))); }
protected void RetargetProjects( DotNetInstallation dotNetInstall, string rootDir, IEnumerable <string> projectFileRelativePaths) { if (string.IsNullOrWhiteSpace(rootDir)) { throw new ArgumentNullException(rootDir); } if (!Directory.Exists(rootDir)) { throw new DirectoryNotFoundException($"Root directory was not found: {rootDir}"); } foreach (string projectFileRelativePath in projectFileRelativePaths) { string projectFile = Path.Combine(rootDir, projectFileRelativePath); if (!File.Exists(projectFile)) { throw new FileNotFoundException($"Project file was not found: {projectFile}"); } var doc = new XmlDocument(); Encoding docEncoding; using (var fs = new FileStream(projectFile, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var sr = new StreamReader(fs)) { docEncoding = sr.CurrentEncoding; doc.Load(sr); } XmlElement root = doc.DocumentElement; // Comment out all existing TargetFramework and RuntimeFrameworkVersion elements foreach (XmlElement e in root.SelectNodes("PropertyGroup/TargetFramework").OfType <XmlElement>()) { e.ParentNode.ReplaceChild(doc.CreateComment(e.OuterXml), e); } foreach (XmlElement e in root.SelectNodes("PropertyGroup/RuntimeFrameworkVersion").OfType <XmlElement>()) { e.ParentNode.ReplaceChild(doc.CreateComment(e.OuterXml), e); } // Add TargetFramework and RuntimeFrameworkVersion elements with the requested values to the top { XmlElement propertyGroupElement = doc.CreateElement("PropertyGroup"); root.PrependChild(propertyGroupElement); XmlElement targetFrameworkElement = doc.CreateElement("TargetFramework"); XmlElement runtimeFrameworkVersionElement = doc.CreateElement("RuntimeFrameworkVersion"); propertyGroupElement.AppendChild(targetFrameworkElement); propertyGroupElement.AppendChild(runtimeFrameworkVersionElement); targetFrameworkElement.InnerText = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); runtimeFrameworkVersionElement.InnerText = dotNetInstall.FrameworkVersion; } using (var fs = new FileStream(projectFile, FileMode.Truncate, FileAccess.Write, FileShare.Read)) using (var sw = new StreamWriter(fs, docEncoding)) { doc.Save(sw); } } }
public abstract Task Setup(DotNetInstallation dotnetInstall, string intermediateOutputDir, bool useExistingSetup, ITestOutputHelper output);