Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,29 @@ temp/
*.lck
/coverage
xunit.xml
javac*.log
javac*.log
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Xx]64/
[Xx]86/
[Bb]uild/
bld/
[Bb]in/
[Oo]bj/

# Visual Studio 2015 cache/options directory
**/.vs/*

# DNX
project.lock.json
artifacts/
Binary file added .vs/slnx.sqlite
Binary file not shown.
6 changes: 6 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ function input() {
store: true,
message: 'What type of application do you want to create?',
choices: [
{
name: 'ASP.NET.Core.MVC',
value: 'aspcoremvc'
},
{
name: '.NET Core',
value: 'asp'
Expand Down Expand Up @@ -248,6 +252,8 @@ function input() {
function configGenerators() {
if (this.type === 'asp') {
this.composeWith('vsts:asp', { args: [this.applicationName, this.installDep] });
} else if (this.type === 'aspcoremvc') {
this.composeWith('vsts:aspcoremvc', { args: [this.applicationName, this.installDep] });
} else if (this.type === 'node') {
this.composeWith('vsts:node', { args: [this.applicationName, this.installDep, this.target, this.dockerHost ? this.dockerHost : ""] });
} else {
Expand Down
109 changes: 109 additions & 0 deletions generators/aspcoremvc/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
const path = require('path');
const generators = require('yeoman-generator');

function construct() {
// Calling the super constructor is important so our generator is correctly set up
generators.Base.apply(this, arguments);

// Order is important
this.argument('applicationName', { type: String, required: true, desc: 'the name of the application' });
this.argument('installDep', { type: String, required: false, desc: 'if true dependencies are installed' });
}

function writeFiles() {
var tokens = {
name: this.applicationName,
name_lowercase: this.applicationName.toLowerCase()
};

var src = this.sourceRoot();
var root = this.applicationName;

// Root files
this.copy(`${src}/README.md`, `${root}/README.md`);
this.copy(`${src}/gitignore`, `${root}/.gitignore`);
this.copy(`${src}/global.json`, `${root}/global.json`);
this.copy(`${src}/latest_dotnet.ps1`, `${root}/latest_dotnet.ps1`);


// Web App project
src = `${this.sourceRoot()}/src/app`;
root = `${this.applicationName}/src/${this.applicationName}`;
this.fs.copyTpl(`${src}/.bowerrc`, `${root}/.bowerrc`, tokens);
this.fs.copyTpl(`${src}/bower.json`, `${root}/bower.json`, tokens);

// Project files
this.copy(`${src}/App.csproj`, `${root}/App.csproj`);
this.fs.copyTpl(`${src}/App.xproj`, `${root}/App.xproj`, tokens);
this.fs.copyTpl(`${src}/project.json`, `${root}/project.json`, tokens);
this.copy(`${src}/project.lock.json`, `${root}/project.lock.json`);

this.directory(`${src}/wwwroot`, `${root}/wwwroot`);
this.directory(`${src}/Views/Home`, `${root}/Views/Home`);

this.copy(`${src}/web.config`, `${root}/web.config`);
this.copy(`${src}/appsettings.json`, `${root}/appsettings.json`);
this.copy(`${src}/bundleconfig.json`, `${root}/bundleconfig.json`);
this.copy(`${src}/Views/_ViewStart.cshtml`, `${root}/Views/_ViewStart.cshtml`);
this.copy(`${src}/Views/Shared/Error.cshtml`, `${root}/Views/Shared/Error.cshtml`);

// this.fs.copyTpl(`${src}/Dockerfile`, `${root}/Dockerfile`, tokens);
this.fs.copyTpl(`${src}/Program.cs`, `${root}/Program.cs`, tokens);
this.fs.copyTpl(`${src}/Startup.cs`, `${root}/Startup.cs`, tokens);

this.fs.copyTpl(`${src}/Views/_ViewImports.cshtml`, `${root}/Views/_ViewImports.cshtml`, tokens);
this.fs.copyTpl(`${src}/Views/Shared/_Layout.cshtml`, `${root}/Views/Shared/_Layout.cshtml`, tokens);
this.fs.copyTpl(`${src}/Controllers/HomeController.cs`, `${root}/Controllers/HomeController.cs`, tokens);
this.fs.copyTpl(`${src}/Properties/launchSettings.json`, `${root}/Properties/launchSettings.json`, tokens);

// Now test project
src = `${this.sourceRoot()}/test/app.tests`;
root = `${this.applicationName}/test/${this.applicationName}.Tests`;

this.fs.copyTpl(`${src}/project.json`, `${root}/project.json`, tokens);
this.fs.copyTpl(`${src}/HomeControllerTest.cs`, `${root}/HomeControllerTest.cs`, tokens);
}

function install() {
var done = this.async();

if (this.installDep === 'true') {
process.chdir(`${this.applicationName}/src/${this.applicationName}`);

this.log(`+ Running bower install`);
// I don't want to see the output of this command
this.spawnCommandSync('bower', ['install'], { stdio: 'pipe' });

this.log(`+ Running dotnet restore`);
this.spawnCommandSync('dotnet', ['restore'], { stdio: 'pipe' });
}

done();
}

module.exports = generators.Base.extend({
// The name `constructor` is important here
constructor: construct,

// 1. Your initialization methods (checking current project state, getting configs, etc)
initializing: undefined,

// 2. Where you prompt users for options (where you'd call this.prompt())
prompting: undefined,

// 3. Saving configurations and configure the project (creating .editorconfig files and other metadata files)
configuring: undefined,

// 4. default - If the method name doesn't match a priority, it will be pushed to this group.

// 5. Where you write the generator specific files (routes, controllers, etc)
writing: writeFiles,

// 6. conflicts - Where conflicts are handled (used internally)

// 7. Where installation are run (npm, bower)
install: install,

// 8. Called last, cleanup, say good bye, etc
end: undefined
});
19 changes: 19 additions & 0 deletions generators/aspcoremvc/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Welcome to ASP.NET Core

## This application consists of:

* Sample pages using [ASP.NET Core MVC](http://dot.net) with [Razor](https://docs.asp.net/en/latest/mvc/overview.html#razor-view-engine)
* [Bower](https://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side libraries
* Theming using [Bootstrap](https://go.microsoft.com/fwlink/?LinkID=398939)

## This application was developed with:

* [Visual Studio Code](https://www.visualstudio.com/products/code-vs)
* [Team Services](https://www.visualstudio.com/products/visual-studio-team-services-vs)
* [Yeoman](http://yeoman.io/)

## This application can deploy to:

* [Azure App Service](https://azure.microsoft.com/en-us/services/app-service/)
* [Azure IaaS Linux via Docker](https://azure.microsoft.com/en-us/services/virtual-machines/)
* [Azure Container Service](https://azure.microsoft.com/en-us/services/container-service/)
Loading