kriasoft/aspnet-starter-kit

Open in Visual Studio 2015

JasonWeiseUnreal opened this issue · 4 comments

Does anyone know a tidy way to import / create this in Visual Studio 2015.
At work we use VS2015 Enterprise and am unable to download VS Code.

I have tried "New Project from Existing files" but you cannot select a ASP.NET core project type and any other type has trouble with dependencies (even after manually running npm install)

I whipped out my personal laptop and installed VS Core and it worked fine, just cannot find a way to open it in Visual Studio 2015, any ideas ?

Thanks in advance.

I guess this project is inspired by https://github.com/kriasoft/react-static-boilerplate. And the .NET Core server was just added as a sub-folder. This is supported in Visual Studio Code, but not in Visual Studio 2015 AFAIK.

I've successfully changed the project to be able to run in Visual Studio 2015. Here is a guide.

Configure Visual Studio

  1. Install VS Update 3 and .NET Core Preview Tools.
  2. Configure Visual Studio to use Node 6 instead of the Node version that ships with Visual Studio. Required because this project used ES6/7 features.
  3. Install NPM Task Runner extension. Optional... but will make it a lot easier.
  4. Install Webpack Task Runner. Optional... but if you want to use IIS Express then the watch feature is needed.
  5. If you have R#... make sure it uses ES6 for validating your files. Also have a look here to remove editor warnings.

Change project
Do this before opening the project in Visual Studio 2015 the first time.

  1. Move all files from the /Server folder to the root and update all references in: run.js (3 places). package.json (postinstall) and .vscode/launce.json (2 places). Yes, it's a mess... there are ways to clean it up.
  2. Delete Server.test and remove references in: package.json (postinstall). .vscode/tasks.json. This is just to get it running fast.
  3. Delete global.json, which is not needed now that the .NET Core project is in the root.
  4. Rename public to wwwroot. This is important to have Visual Studio know which folder contains the static files, and if you want to use IIS Express. There are ways to configure VS to use another folder.
  5. Configure IIS Express to run on port 5000 (properties on project).

To run there is a two options:

NPM/Node

  1. First Run npm install. In VS you can right click > Run on install in NPM Task Runner.
  2. Run npm start - again you can right click start > Run on start in NPM Task Runner. Now everything should work with hotreload and everything.
  3. Consider setting events bindings in NPM Task Runner.

IIS Express
If you don't want to use Node as webserver, you can use webpack directly

  • Run webpack. You can right click > Run on "Run - Developent" in Webpack task runner .
  • Press F5 in Visual Studio to start IIS Express.

This also works... but without hot reload... take a look here. Also you should consider running Webpack in watch mode.

visual studio 20015 support

As an update to this incredibly helpful post by @tjementum , it should be noted that the project.json file will be replaced by csproj in a near future update. So wouldn't get to deep into the project.json issue.

Also, you can keep the server code in the server folder, you don't have to move all of it up one dir. You just have to move the project.json and appsettings.json which appears to be hardcoded as a path. And so don't delete the global.json in this case either (to map to your Server folder). The rest is spot on required.

I ended up changing some things to improve it..
The project.json now has:

 "scripts": {
    "prebuild": [
      "node run build"
    ],
  }

since in visual studio the .vscode tasks.json doesn't do anything.
Also had to edit the build pre-op (run.js):

tasks.set('build', () => {
  global.DEBUG = process.argv.includes('--debug') || false;
  return Promise.resolve()
    .then(() => run('clean'))
    .then(() => run('bundle'));
// removed copy (as if it's already in wwwroot, whats the point)
// removed appsettings since I also removed the promise call for msbuild. Since ms handles it fine.
});

And also edit project.json to support the paths..

"publishOptions": {
    "include": [
      "ServerSide/Views",
      "ServerSide/**/*.cshtml",
      "wwwroot",
    ],
    "includeFiles": [
      "ServerSide/appsettings.json",
      "ServerSide/appsettings.Production.json",
      "ServerSide/web.config"
    ],
    "mappings": {
      "ServerSide": "./**/*",
    }
  },

If you have all of your paths correct in the edited json files, everything should be happy. You can hit build from vstudio and it'll run everything proper.

I'll update more if I end up making any significant milestones, but the above guide really sets you up well.

Edit: See here:
http://angularfirst.com/asp-net-core-migrating-to-msbuild/
and here:
https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/dotnet-migrate

Edit2:
I ended up doing a total conversion of the project for visual studio. If anyone is interested in the source for that I'll see about making a fork. Till then...

A fork could be useful.

Just to add to this - I did create a fork here using the steps supplied by @tjementum above

https://github.com/codingupastorm/aspnet-starter-kit-vs-2015