diff --git a/lib/compilers/dotnet.ts b/lib/compilers/dotnet.ts index fc94ec21f26..5a1f4c12f9d 100644 --- a/lib/compilers/dotnet.ts +++ b/lib/compilers/dotnet.ts @@ -54,8 +54,6 @@ class DotNetCompiler extends BaseCompiler { private readonly crossgen2Path: string; private readonly sdkMajorVersion: number; - private versionString: string; - constructor(compilerInfo: PreliminaryCompilerInfo, env) { super(compilerInfo, env); @@ -73,7 +71,6 @@ class DotNetCompiler extends BaseCompiler { this.corerunPath = path.join(this.clrBuildDir, 'corerun'); this.crossgen2Path = path.join(this.clrBuildDir, 'crossgen2', 'crossgen2.dll'); this.asm = new DotNetAsmParser(); - this.versionString = ''; this.disassemblyLoaderPath = path.join(this.clrBuildDir, 'DisassemblyLoader', 'DisassemblyLoader.dll'); } @@ -476,15 +473,13 @@ class DotNetCompiler extends BaseCompiler { } } - async checkRuntimeVersion() { - if (!this.versionString) { - const versionFilePath = `${this.clrBuildDir}/version.txt`; - if (fs.existsSync(versionFilePath)) { - const versionString = await fs.readFile(versionFilePath); - this.versionString = versionString.toString(); - } else { - this.versionString = ''; - } + async getRuntimeVersion() { + const versionFilePath = `${this.clrBuildDir}/version.txt`; + if (fs.existsSync(versionFilePath)) { + const versionString = await fs.readFile(versionFilePath); + return versionString.toString(); + } else { + return ''; } } @@ -496,8 +491,6 @@ class DotNetCompiler extends BaseCompiler { options: string[], outputPath: string, ) { - await this.checkRuntimeVersion(); - const corerunOptions = ['--clr-path', coreRoot, '--env', envPath].concat([ ...options, this.disassemblyLoaderPath, @@ -508,7 +501,9 @@ class DotNetCompiler extends BaseCompiler { await fs.writeFile( outputPath, - `// coreclr ${this.versionString}\n\n${result.stdout.map(o => o.text).reduce((a, n) => `${a}\n${n}`, '')}`, + `// coreclr ${await this.getRuntimeVersion()}\n\n${result.stdout + .map(o => o.text) + .reduce((a, n) => `${a}\n${n}`, '')}`, ); return result; @@ -523,8 +518,6 @@ class DotNetCompiler extends BaseCompiler { toolSwitches: string[], outputPath: string, ) { - await this.checkRuntimeVersion(); - // prettier-ignore const crossgen2Options = [ this.crossgen2Path, @@ -539,7 +532,7 @@ class DotNetCompiler extends BaseCompiler { await fs.writeFile( outputPath, - `// crossgen2 ${this.versionString}\n\n${result.stdout + `// crossgen2 ${await this.getRuntimeVersion()}\n\n${result.stdout .map(o => o.text) .reduce((a, n) => `${a}\n${n}`, '')}`, );