Source: http://www.cnblogs.com/xishuai/p/visual-studio-2015-preview-asp-net-5-change.html
This blog post directory:
- ASP. 5 Templates
- ASP. NET 5 directory structure
- Front-end management tools
- No compilation development
- Microsoft Git Provider
- IntelliSense and error messages
- Smart Unit Testing
- Waiting to discover ...
The Visual Studio version of the Preview release section explains:
- ASP. 5 Preview runtime with VS2015 Preview only.
- ASP. 5 Preview Tooling with VS2015 preview only.
- ASP. Tooling update for both VS2015 Preview and VS2013 update 4.
- ASP. NET runtime updates, most of which is in VS2013 Update 4 as well.
- WebForm 4.6 Improvement for VS2015 Preview only
In the release notes above, note that the recurring keyword "only", that is, if you want to experience this Microsoft released a series of new things, such as: C # 6.0, ASP. 5, EntityFramework 7.0, etc. (Visual Studio Other versions are not supported at this stage), then first you need to download and install Visual Studio Preview.
In the past when Microsoft released or updated the version of Visual Studio, we developed the ASP, the change is not very big, or you do not feel the change, you feel just download installed a few G update package, but this time Microsoft released the updated ASP . NET, which is undoubtedly huge, first we look at the new features of ASP. 5:
- Unified programming model for Web Forms, MVC, and Web APIs.
- No compile development experience (No-compile), modify code files, no need to compile, just browser refresh.
- Seamless cloud Development Support (Cloud-ready environment configuration).
- New HTTP request pipeline (faster).
- Built-in dependency injection.
- NuGet manages everything, even the runtime itself.
- Run in IIS, or self-host (self-hosted) in the process.
- GitHub Open source means that you can view the source code, or contribute your own code.
- The ASP. NET 5 runs on Windows (keywords:. NET core) on the. NET Framework or. NET Core.
- . NET Core supports parallel versions (Side-by-side versioning).
- ASP. NET 5 can run on OS X and Linux (Mono runtime).
Let's look at what "fresh" things are in the process of using VS2015 to develop ASP. NET 5.
ASP. 5 Templates
VS2013 New asp:
VS2015 New ASP. NET 5 project:
As you can see, using vs 2015 to create a new ASP. NET 5 project, we don't have the option to choose Web Forms, Web APIs like vs 2013, which means that ASP. NET 5 enforces the integration of Web Forms, MVC, and Web APIs into a piece , and there are no separate options for creating their own projects, we can also see from the namespace, such as VS 2013 new ASP.
- The MVC routing configuration namespace is: SYSTEM.WEB.MVC;
- The Web Api routing configuration namespace is: System.Web.Http;
in ASP. NET 5, all the routing configuration namespaces are unified as: Microsoft.AspNet.Routing; Route Configuration Sample code:
app.UseMvc(routes =>
{
//MVC Route
routes.MapRoute(
name: "default", template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
//Web Api Route
routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
});
ASP. NET 5 directory structure
To create a new ASP. NET 5 project, the solution directory structure:
Here is a brief talk about what I have learned, not necessarily accurate, for reference only:
Global.json
The Global.json file is stored in the "solution Items" solution directory, "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 reference S. ", this is an excerpt from an MSDN blog post, when you create a new project, you'll find that the default configuration is in Global.json:
{ "sources": [ "src", "test" ]}
The only configuration I understand is that sources represents the directory structure under this solution, SRC is the solution directory (as can be seen from the above), test for this sources alias, if there are more than one solution directory, directly in the Global.json file to add Sources configuration can be, someone might ask? Why do you configure this? All project management is not configured in *.sln? Open the ASP.NET5.sln file with Notepad and extract a configuration:
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F96F5906-2577-49AD-9693-1809EF74348E}" ProjectSection(SolutionItems) = preProject
global.json = global.json EndProjectSection
ProjectSection(FolderGlobals) = preProject __JSONSchema = http://json.schemastore.org/global EndProjectSection
EndProject
I don't really understand this configuration, but it seems to be very similar to the *.sln saved in the Sublime Text in MAC OS to develop the ASP. NET VNext project, what does that mean? Does it mean that the ASP. NET VNext project developed across platforms can be opened with different development tools? I haven't tried this, but I can see from the JSON-formatted Global.json project configuration file that I think it would be great if I could (which could mean possible)!
Wwwroot
Wwwroot can be seen as the self-hosting (self-hosted) mentioned in the net 5 change point, I do not study this for the time being, you can look at the wwwroot in the specific file directory, in fact, in addition to static files (CSS, JS, etc.), and nothing else, There is also a large heap of assembly files under our common Bin folder, which uses VS2015 to publish the application and also generates a Wwwroot folder, but unlike the solution Wwwroot, the Post folder has a bin file with only one Aspnet.loa Der.dll assembly, what is AspNet.Loader.dll? I am not very clear, Google search, and found a few keywords: OWIN, Helios, and then found a very good article, excerpts from a paragraph:
Helios runtime without OWIN.
In this section we use the Helios runtime assembly named Microsoft.AspNet.Loader.IIS.dll a standalone assembly and It does not has the direct integration with the OWIN pipeline. The application uses the APIs exposed by the Helios rather then using the OWIN extensibility points by the Microsoft.owin. Host.iis.
In addition, in the Properties page of the new ASP.NET5 project, there is one such configuration:
Excerpt from a Zhang Shanyu part of a blog post:
K Runtime Environment (KRE) This is a command-line environment that will build and run (no longer have real differences) from their new Project.json. The ASP. NET VNext merges Packages.config, NuGet configuration (NUSPEC), and project files (CSPROJS) into a unified project dependency configuration file Project.json. There is a simple application K version Manager (KVM) is responsible for installing KRE, can install multiple versions of KRE, and can switch between them freely.
There are four configuration options in KRE target version, with the default option configured as: Kre-clr-x86.1.0.0-beta1, which I did not find relevant information, I only on MSDN To find a partial description of a non-relevant blog post (not specifying the difference between the different options): the ASP. NET 5 Application ' s property Page is a tool window and can be used to specify th e KRE target version, the debug target, and whether binaries and NuGet packages should be created during a Visual Studio b Uild.
Dependencies, References
Dependencies translated as "dependent", References translated as "reference", Dependencies under Two "directory": Bower and NPM, simply said Bower as the front-end files (CSS, JS), can also be a front-end framework, such as Bootstrap, configuration loading via Bower.json, NPM (node package Manage) node. JS's bundle manager, which can be understood as the front end Package manager, is configured through Package.json, all of which are VS2015 To the front-end management to add new things, some are not Microsoft's own things, I am also just beginning to learn, specific how to configure management, there are instructions later.
References is the "Bin" or "reference" that we see in general, and unlike before, there are only ASP. NET 5.0 and ASP. NET Core 5.0, where all the assemblies are passed through dependencies in the Project.json file Row configuration Management, why is the directory structure changed? What is the benefit of not loading all the assemblies under our common "references"? In fact, I think the point is that the reference is more normative, I am new is the ASP. NET 5 type of project, all the assemblies should be applicable to this framework, such as EntityFramework 7.0 is temporarily applicable only to ASP. NET 5, the new As.net 5 Class Lib The same is true of Rary:
Project.json
Project.json is the most important file in the ASP. NET 5 project, which contains many of the configuration of this project, a bit like the Web.config,project.json file that we often use is the JSON format, the corresponding schema is:/http Json.schemastore.org/project, paste the sample code:
{
/* Click to learn more about project.json http://go.microsoft.com/fwlink/?LinkID=517074 */
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"ClassLibrary1": "",
"EntityFramework.SqlServer": "7.0.0-beta1",
"EntityFramework.Commands": "7.0.0-beta1",
"Microsoft.AspNet.Mvc": "6.0.0-beta1",
//"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta1",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta1",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta1",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta1",
"Microsoft.AspNet.Security.Cookies": "1.0.0-beta1",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta1",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta1",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta1",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta1",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta1",
"Microsoft.Framework.Logging": "1.0.0-beta1",
"Microsoft.Framework.Logging.Console": "1.0.0-beta1",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta1"
},
"commands": {
/* Change the port number when you are self hosting this application */
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"gen": "Microsoft.Framework.CodeGeneration",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"aspnet50": { },
"aspnetcore50": { }
},
"exclude": [ "wwwroot", "node_modules", "bower_components"
],
"packExclude": [ "node_modules", "bower_components", "**.kproj", "**.user", "**.vspscc"
],
"scripts": {
"postrestore": [ "npm install" ],
"prepare": [ "grunt bower:install" ]
}
}
Project.json file, the most common configuration we should have is dependencies and commands,commands configuration and I used Sublime Text in MAC OS to develop ASP. Ver.urls custom URLs, just as we use IIS for site domain name binding, dependencies is the reference management of all the assemblies, and all are loaded through Nuget, this is nothing to say, many of the data mentioned, in addition, in Adding an assembly in the dependencies configuration, VS2015 provides a very powerful IntelliSense feature and can also prompt for the version number of this assembly, very cool!
Note that you will find that the assemblies that are now involved in the ASP. NET 5 project begin with "Microsoft", not the most common "System", and the version number is "1.0.0-beta1", although now VS2015 is a preview version, The assembly involved is "Beta" is not a problem, but the "1.0.0" version of the name is actually some flavor inside, I remember inadvertently read a blog post, about the current design of ASP. NET 5 Framework update problem, roughly meaning that the current version is "Brand new", Not in the previous version of the "expansion", and then it explains a lot of the previous Framework version of the problem, I am sorry, I just roughly remember, specifically, which of the blog post.
Other files
Controllers, Models, and views are no different from the ASP. NET MVC Project we developed earlier, migrations is a sample project that uses EntityFramework code to migrate files, Startup.cs and OWIN projects as The project startup configuration is similar to the previous global.cs.
Front-end management tools
In VS2015, Microsoft added the external Front end management tool, which was never in the previous VS version, and these are new things to me, first of all need to know several keywords:
If you don't know them, you can learn from the following blog posts:
- Day 1:bower--Manage your client dependencies
- About Grunt, start with a simple configuration!
- One of the front-end soft skills-automated build tool Yeoman
- Front-end working mode Yeoman (Yo, Grunt, Bower)
- Introduction to Gulp, Grunt, Bower, and NPM support for Visual Studio
Speaking of my own understanding of these, Bower can be regarded as "raw material provider", NPM can be regarded as "the supplier of tools", Grunt can be regarded as "concrete tools", what does that mean? The production of a "product" requires tools to process raw materials, what raw materials are selected, Bower (configuration management through Bower.json), and NPM provides tools for processing these raw materials (through Package.json configuration management), such as Grunt, The final processing of the molded product (through Gruntfile.js configuration management), which said that the "processing", in fact, is the release management.
In addition, in VS2015, a Task Runner Explorer Management window is provided, which functions as a "visual" management of the tools provided by NPM (e.g. Grunt):
No compilation development
No compilation development refers to the use of VS2015 to develop an ASP. NET 5 project, modify the code file, do not need to recompile the build, just save and refresh the browser, a picture illustrates:
Microsoft Git Provider
Microsoft Git Provider is the default code-management tool provided by VS2015, and we used to install a "git Source Control Provider" in VS in other versions of VS, if the code is managed using Git. The plugin, but the base is the need to install Git Extensions, a git plugin built into the VS2015, and very powerful, really do not have to know, a scare jump.
Isn't it really cool? I feel cool, you can get a lot of Git information from this, each method name has a last submitted author information, as well as update time display, click on this prompt, there will be a chart to show the update point, and then click will have this update point specific information ...
VS2015 in this function, in short a word "bunker."
IntelliSense and error messages
The IntelliSense feature in VS2015 is primarily manifested in whether its code implementation is contained within a framework, such as:
A description of the error message, read a blog post on MSDN, is not very clear, the general meaning is that the error message can show the implementation of different frameworks, which refers to the References of ASP. NET 5.0 and ASP. 5.0, in fact, I do not really understand the specific role of these two frameworks, later in the use of the time to explore it.
Another feature is that if an error occurs, VS2015 will "tell" you: How should the code be written?
Smart Unit Testing
Smart Unit testing formerly known as PEX, is said to come from Microsoft Research Technology, about the introduction: Generate Smart unit tests for your code.
In VS2015, integrating the smart unit testing makes it incredibly easy for us to do unit testing, you just need to "right-click" in the method you need to test and then click "Smart Unit Testing":
Smart Unit Testing window:
When we do this, it is important to note that there is no unit test project for the new unit tests, but simply a unit test using VS2015, which means that we are not writing the unit test code and testing the source code directly using the test tool. This way and we use the traditional XUnit test is different, of course, there are advantages and disadvantages, the choice of problems, suitable for good.
How does the Visual Studio 2015 development ASP. NET 5 change? Now it's just fur, that is, some superficial things, really to understand and use it, only through the actual project application, currently, Visual Studio 2015 Development of ASP. NET 5 is not so simple, there are many things to learn, This blog post hopes to bring you some help.
Resources:
- Musicstore
- Project.json file
- Visual Studio Preview
- ASP. VNext in Visual Studio "+" CTP 4
- dditional information about ASP. Helios
- Announcing ASP. Features in Visual Studio Preview and VS2013 Update 4
- Manage client-side Web Development in Visual Studio, Using Grunt and Bower | The ASP. NET Site
- I can't remember.
How does the Visual Studio 2015 development ASP. NET 5 change? (GO)