Use correct docker base image for csproj projects. Fixes #574.

This commit is contained in:
SteveSandersonMS
2017-01-16 15:25:41 +00:00
parent f8714e9653
commit 1a49a27344
3 changed files with 14 additions and 4 deletions

View File

@@ -30,7 +30,8 @@ const templates: { [key: string]: { dir: string, dotNetNewId: string, displayNam
}; };
function isTextFile(filename: string): boolean { function isTextFile(filename: string): boolean {
return textFileExtensions.indexOf(path.extname(filename).toLowerCase()) >= 0; return textFileExtensions.indexOf(path.extname(filename).toLowerCase()) >= 0
|| textFileExtensions.indexOf(path.basename(filename)) >= 0;
} }
function writeFileEnsuringDirExists(root: string, filename: string, contents: string | Buffer) { function writeFileEnsuringDirExists(root: string, filename: string, contents: string | Buffer) {
@@ -92,6 +93,9 @@ function buildYeomanNpmPackage(outputRoot: string) {
{ from: /.*\.csproj$/, to: 'tokenreplace-namePascalCase.csproj' } { from: /.*\.csproj$/, to: 'tokenreplace-namePascalCase.csproj' }
]; ];
const contentReplacements = [ const contentReplacements = [
// Dockerfile items
{ from: /FROM microsoft\/dotnet:1.1.0-sdk-projectjson/g, to: 'FROM <%= dockerBaseImage %>' },
// .xproj items // .xproj items
{ from: /\bWebApplicationBasic\b/g, to: '<%= namePascalCase %>' }, { from: /\bWebApplicationBasic\b/g, to: '<%= namePascalCase %>' },
{ from: /<ProjectGuid>[0-9a-f\-]{36}<\/ProjectGuid>/g, to: '<ProjectGuid><%= projectGuid %></ProjectGuid>' }, { from: /<ProjectGuid>[0-9a-f\-]{36}<\/ProjectGuid>/g, to: '<ProjectGuid><%= projectGuid %></ProjectGuid>' },

View File

@@ -50,11 +50,13 @@ const templates = [
const sdkChoices = [{ const sdkChoices = [{
value: '1.0.0-preview2-1-003177', // Current released version value: '1.0.0-preview2-1-003177', // Current released version
name: 'project.json' + chalk.gray(' (compatible with .NET Core tooling preview 2 and Visual Studio 2015)'), name: 'project.json' + chalk.gray(' (compatible with .NET Core tooling preview 2 and Visual Studio 2015)'),
includeFiles: [/^project.json$/, /\.xproj$/, /_placeholder.txt$/, /\.deployment$/] includeFiles: [/^project.json$/, /\.xproj$/, /_placeholder.txt$/, /\.deployment$/],
dockerBaseImage: 'microsoft/dotnet:1.1.0-sdk-projectjson'
}, { }, {
value: '1.0.0-preview3-004056', // Version that ships with VS2017RC value: '1.0.0-preview3-004056', // Version that ships with VS2017RC
name: '.csproj' + chalk.gray(' (compatible with .NET Core tooling preview 3 and Visual Studio 2017)'), name: '.csproj' + chalk.gray(' (compatible with .NET Core tooling preview 3 and Visual Studio 2017)'),
includeFiles: [/\.csproj$/] includeFiles: [/\.csproj$/],
dockerBaseImage: 'microsoft/dotnet:1.1.0-sdk-msbuild'
}]; }];
class MyGenerator extends yeoman.Base { class MyGenerator extends yeoman.Base {
@@ -110,6 +112,10 @@ class MyGenerator extends yeoman.Base {
this._answers.sdkVersion = firstAnswers.sdkVersion; this._answers.sdkVersion = firstAnswers.sdkVersion;
this._answers.namePascalCase = toPascalCase(answers.name); this._answers.namePascalCase = toPascalCase(answers.name);
this._answers.projectGuid = this.options['projectguid'] || uuid.v4(); this._answers.projectGuid = this.options['projectguid'] || uuid.v4();
const chosenSdk = sdkChoices.filter(sdk => sdk.value === this._answers.sdkVersion)[0];
this._answers.dockerBaseImage = chosenSdk.dockerBaseImage;
done(); done();
}); });
}); });

View File

@@ -1,6 +1,6 @@
{ {
"name": "generator-aspnetcore-spa", "name": "generator-aspnetcore-spa",
"version": "0.7.3", "version": "0.7.4",
"description": "Single-Page App templates for ASP.NET Core", "description": "Single-Page App templates for ASP.NET Core",
"author": "Microsoft", "author": "Microsoft",
"license": "Apache-2.0", "license": "Apache-2.0",