Visual Studio 2015 Tooling

Support for Modern Front-end Web Development Practices

ASP.NET and Visual Studio 2015 also now support modern front-end web development practices, meaning they include integration with JavaScript package manager (think NuGet for JavaScript) like Node Package Manager (NPM) and Bower, the package manager for client frameworks like Bootstrap and Angular. The new tooling also includes support for automated build and compilations steps, like Grunt or Gulp. Grunt or Gulp are popular task runners that, similar to a build system for server code, do the same build optimization steps for client-side JavaScript, like minifying your JavaScript by removing whitespaces and carriage returns. For developers building Docker images, this is important as you’ll need to ensure that any pre-compilation tasks happen as part of the Docker image creation process as discussed in Chapter 4. These tasks can be specified in a project.json scripts section that installs NPM and Bower, and then runs Gulp tasks to clean and minify content.

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean",
"gulp min" ]
  }

The default minify task, for example, calls two tasks:

gulp.task("min", ["min:js", "min:css"]);

The min:js task uses the built-in uglify() method to convert readable javascript into obfuscated code. The CSS task, on the other hand, minifies the CSS contents to reduce the amount of bytes sent over the wire. You don’t have to understand how these tasks work, but the important part is to ensure that these tasks run as part of the Docker image creation, either as part of the normal Visual Studio publishing process, or via an automated build and continuous integration process.

gulp.task("min:js", function () {
    gulp.src([paths.js, "!" + paths.minJs], { base: "." })
        .pipe(concat(paths.concatJsDest))
        .pipe(uglify())
        .pipe(gulp.dest("."));
});

gulp.task("min:css", function () {
    gulp.src([paths.css, "!" + paths.minCss])
        .pipe(concat(paths.concatCssDest))
        .pipe(cssmin())
        .pipe(gulp.dest("."));
});

Easily Build REST Proxies for Microservices

One of the coolest and least-known features available in Visual Studio 2015 is the capability to create a client proxy based on Swagger metadata for a REST service. Swagger is a standard, language-agnostic way to describe your REST APIs. A Swagger file includes information about your API’s custom data types, inputs, return types, resources, and more. This has the benefit of making your APIs self-describing so developers and tools can understand how to use your APIs. It also means that tools can automatically create client proxies in Java, .NET, Node, Python, Ruby, and a host of other languages for a Swagger service. For .NET developers, Visual Studio includes the capability to provide a URI to the Swagger metadata, and it will build a custom proxy available as source code in your project for you to call the service. If this sounds familiar, it is similar to SOAP (Simple Object Access Protocol) and WSDL (Web Service Description Language), which provided similar capabilities more than a decade ago. The difference with Swagger is that REST services are inherently lighter-weight and simpler than a SOAP service, and for SOAP services the generated proxy from tools was provided as a DLL, meaning that a developer could not add to or modify the code. With auto-generated Swagger classes, the source code for the service is provided to you so you can add, edit, or modify it to your heart’s content.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.187.210