diff --git a/.gitignore b/.gitignore index 1c9a181..0c1bc41 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs - +nuget.exe # Build results [Dd]ebug/ [Dd]ebugPublic/ diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..3820b7a --- /dev/null +++ b/Readme.md @@ -0,0 +1,41 @@ +This is an example of a webforms project being compiled into a docker container. The gulp file is used for build orchestration. This is for **windows 10** or **server 2016** + +## Gettting started + +Install docker with [this script on windows 10](https://gist.github.com/TerribleDev/dd424d3d090bcf5634dcf8417411a081), or setup docker on [server 2016](https://gist.github.com/TerribleDev/106197d88d1535dd0546165f5a7eb6a8) + +Install nodejs + +run: +``` +npm install -g gulp +npm install +``` + +## tasks + + + +`clean:` clean up artifacts + +`retrieve:` alias for retrieve docker image and nuget + +`build:` build everything + +`restore:nuget` restores nugets + +`build:patchAssemblyInfo` patch assemblyinfo cs files + +`build:csharp` compile csharp + +`build:dockerImage` build the docker image + + +arguments: +`--version` version to set for assemblyinfo docker image + +usage: + +`gulp build --version 1.0.1` + + diff --git a/WebForms1/.gitignore b/WebForms1/.gitignore new file mode 100644 index 0000000..6caf68a --- /dev/null +++ b/WebForms1/.gitignore @@ -0,0 +1 @@ +output \ No newline at end of file diff --git a/WebForms1/Dockerfile b/WebForms1/Dockerfile new file mode 100644 index 0000000..c90314f --- /dev/null +++ b/WebForms1/Dockerfile @@ -0,0 +1,3 @@ +FROM microsoft/aspnet +ARG site_root=. +ADD ${site_root} /inetpub/wwwroot \ No newline at end of file diff --git a/WebForms1/WebForms1.csproj b/WebForms1/WebForms1.csproj index 1d20dc0..ec0dd22 100644 --- a/WebForms1/WebForms1.csproj +++ b/WebForms1/WebForms1.csproj @@ -116,6 +116,7 @@ + @@ -224,7 +225,7 @@ - True + False True 53523 / diff --git a/WebForms1/p.pubxml b/WebForms1/p.pubxml new file mode 100644 index 0000000..5fbd547 --- /dev/null +++ b/WebForms1/p.pubxml @@ -0,0 +1,11 @@ + + + FileSystem + Release + Any CPU + + False + .\output + True + + \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..b909ad1 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,66 @@ +var gulp = require('gulp'); +var request = require('request'); +var fs = require('fs'); +var nuget = require('gulp-nuget'); +var request = require('request'); +var child_process = require('child_process'); +var msbuild = require('gulp-msbuild'); +var assemblyInfo = require('gulp-dotnet-assembly-info'); +var argv = require('yargs') + .default('version', '1.0.0').argv; +var del = require('del'); + +gulp.task('retrieve', ['restore:nuget', 'restore:dockerImage']); +gulp.task('build', ['build:csharp', 'build:dockerImage']) + +gulp.task('clean', ()=>{ + return del(['nuget.exe', 'packages', 'WebForms1/output']) +}); + +gulp.task('download:nuget', ['clean'] ,(cb)=>{ + return request('http://nuget.org/nuget.exe') + .pipe(fs.createWriteStream('nuget.exe')); +}); + +gulp.task('restore:nuget', ['clean','download:nuget'], ()=>{ + return gulp.src('WebForms1.sln') + .pipe(nuget.restore({ nuget: "./nuget.exe" })); +}); + +gulp.task('restore:dockerImage', ()=>{ + //so help my soul for making this sync + child_process.execSync('docker pull microsoft/aspnet', {stdio: 'inherit'}) +}); + +gulp.task('build:patchAssemblyInfo', function() { + gulp.src(['**/AssemblyInfo.cs', '!packages/**']) + .pipe(assemblyInfo({ + title: 'Planet Express Website', + description: 'Shipping and tracking website.', + configuration: 'Release', + company: 'Planet Express', + product: 'Planet Express Website', + copyright: 'Copyright 3002 © Planet Express', + trademark: 'Planet Express', + culture: 'en-us', + version: function(value) { return argv.version }, + fileVersion: function(value) { return argv.version; }, + })) + .pipe(gulp.dest('.')); +}); + + +gulp.task('build:csharp', ['retrieve', 'build:patchAssemblyInfo'], ()=>{ + return gulp.src("./WebForms1/WebForms1.csproj") + .pipe(msbuild({ + targets: ['Clean', 'Build'], + properties: { Configuration: 'Release', DeployOnBuild: 'true', PublishProfile: '.\\p.pubxml' }, + toolsVersion: 14 + }) + ); +}); + +gulp.task('build:dockerImage', ['build:csharp', 'restore:dockerImage'], ()=>{ + //so help my soul for making this sync + child_process.execSync(`docker build -t tparnell/mywebforms:${argv.version} .`, {stdio: 'inherit', cwd: "./WebForms1/output"}) +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..07a4f50 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "webforms1", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "del": "^2.2.2", + "gulp": "^3.9.1", + "gulp-dotnet-assembly-info": "^0.1.12", + "gulp-msbuild": "^0.4.1", + "gulp-nuget": "^1.0.1", + "request": "^2.75.0", + "yargs": "^6.2.0" + } +}