ASP.NET vNext in Visual Studio “14” CTP 4

Xinyang Qiu

Today we released updates for ASP.NET vNext in Visual Studio “14” CTP 4. This release includes the ASP.NET vNext runtime and tooling improvements as outlined below.

ASP.NET vNext Runtime

This CTP includes our alpha4 runtime packages for ASP.NET vNext. You can find details on the specific enhancements added and issues fixed in the published release notes on GitHub.

For information on how to get started with ASP.NET vNext using Visual Studio “14” check out the article Getting Started with ASP.NET vNext and Visual Studio “14”.

The MVC Music Store and Bug Tracker sample projects have been updated for this release. You can find instructions on how to open, build, run, and publish these sample ASP.NET vNext projects in the documentation in the corresponding GitHub repos.

There are a few notable breaking changes in this release from Visual Studio “14” CTP3:

  • Project.json now uses “aspnet50” and “aspnetcore50” as framework values, instead of “net45” and “k10”.
  • Project.json has a new “webroot” element to indicate the static content folder and an “exclude” element for folders to be excluded from compilation.
  • The Startup.cs IBuilder parameter was renamed to IApplicationBuilder.

ASP.NET vNext Tooling

Performance improvements to compilation in Visual Studio

VS uses the Roslyn engine to compile ASP.NET vNext projects at design time. Therefore the project has already been compiled when you issue a “build” request. In Visual Studio “14” CTP4, VS simply passes the design time compiler output to the build request. This avoids another build and improves performance when you build, run, or debug ASP.NET vNext projects.

NuGet Package Manager support

Visual Studio now supports the NuGet Package Manager and console for ASP.NET vNext projects.

image_thumb[10]

To use this UI for upgrading current alpha ASP.NET vNext packages, click the Settings button and add package sources from developing sources:

New layout for ASP.NET vNext solutions and projects

ASP.NET vNext solutions created in project template now has a new project layout. While this new layout is not required, it helps with cleanly separating your application source code from other artifacts in your solution. New solutions now contain a <solutionFolder>src folder for your application projects. A top level global.json file indicates the src folder can be used for looking up project references. This makes it easy to separate test code under a different folder, but still be able to reference application projects from your test projects. For test projects, we recommend to put them under <solutionFolder>test directory. 

ASP.NET vNext web project template also puts static contents under the wwwroot folder that is determined by the webroot element of project.json.

image_thumb[3][4]

Global.json file in new solutions for project-to-project references

In the previous picture, you can see a global.json file in the same level as the solution file, to make better support for project-to-project references. It contains “sources”: [“src”] element, indicating the “src” folder as the parent folder for looking for project references.

By default, project-to-project references lookup will use parent directory, plus the global.json-defined directories. For example, we have the following solution structure and project.json dependency visibility:

Solution1global.json

content {“sources”: [“src”] }

Solution1srcWebApp1

Possible Dependencies: ”ClassLib1” :””

Solution1srcClassLib1

Possible Dependencies: ”WebApp1” :””

Solution1testTestProj1

Possible Dependencies: ”WebApp1” :””, ”ClassLib1” :””, ”TestProj2” :””

Solution1testTestProj2

Possible Dependencies: ”WebApp1” :””, ”ClassLib1” :””, ”TestProj1” :””

We only need two simple steps to add an ASP.NET vNext class library reference to the default ASP.NET vNext web application.

1. In Solution Explorer, add a new project under the “src” folder. Note, we need to append the “src” folder to the “Add New Project” Location edit box manually at this time. (VS will do this automatically in a future release.)

image_thumb[4]_thumb

2. Open web project’s project.json file, add “ClassLibrary1”:”” inside the “dependencies” element

image_thumb[6][1]

Debugging support for ASP.NET vNext unit tests

In VS “14” CTP3, support was added for running xUnit.NET tests in the VS Test Explorer tool window. VS “14” CTP4 now supports debugging tests from the tool window as well.

image_thumb[8][1]

Immediate refresh of the Project References node for project.json dependency changes

In this release, we enhanced ASP.NET vNext project References node behavior to immediately reflect project.json file dependency changes, while the package checking and loading happens in the background.

Known Issues

1. There are some known tooling issues with the new solution structure, which you need to be careful about, especially when adding project-to-project references:

    • When you create a new ASP.NET vNext project, an empty project folder is created under the solution folder. This folder should be removed, because the real project folder is created under <solutionFolder>src subfolder.
    • In an ASP.NET vNext project, when you right-click the solution “src” folder or solution node, and add a new project to it (say ClassLibrary1), the Add New Project file dialog uses the solution folder as the location, instead of the “src” location. Project-to-project references will not work properly at runtime as a result.

clip_image011_thumb[1]_thumb

To work around the problem, you need to add “.” (current folder) to the list of project folders specified in global.json : “sources”: [ “src”, “.” ], or move the project folder to the “src” folder manually.

2.  With the new solution structure, you will run into some issues if you uncheck the ‘Create directory for solution’ checkbox in the File > New Project dialog. Due to some quirks in the way this checkbox is handled internally, if you specify a custom location for your projects in the New Project dialog (e.g.: C:Tests instead of using the default path provided by VS), you will find that projects in the src folder still get created in the default projects path rather than under the custom path that you provided.

3. On Windows 8 RTM, pressing F5 in an ASP.NET vNext project does not work for the Core CLR framework. Ctrl + F5 works fine. Pressing F5 works fine for core CLR framework on Windows 8.1.

4. Three Core CLR package versions were downgraded due to a restructure of the Core CLR packages.  If you installed VS “14” CTP4 on a machine that you’ve already used ASP.NET vNext on before, clear out %userprofile%kpmpackages to ensure projects can successfully build and run. They are:

  • System.Text.Encoding from 4.0.20.0 to 4.0.10.0
  • System.IO.FileSystem from 4.0.10.0 to 4.0.0.0
  • System.IO.FileSystem.Primitives from 4.0.10.0 to 4.0.0.0

Summary

We’d love to hear your feedback. For Visual Studio tooling related issues, please submit bugs through Connect, send suggestions on UserVoice and quick thoughts via Send-a-Smile in the Visual Studio IDE. For ASP.NET vNext, please provide feedback in GitHub or the ASP.NET vNext forum. If you ask a question in Stack Overflow, use the asp.net-vnext tag.  Thanks for being with us in this exciting time!

0 comments

Discussion is closed.

Feedback usabilla icon