Skip to content →

ASP.NET vNext – Packing and Publishin

These are my notes from the ASP.NET vNext Community Standup

Packing and Publishing

Packing and Publishing is the process of taking the source and static files as they are represented in my source tree and staging them into a folder structure ready to xcopy onto a server.

The underlying process uses the KPM command line tool, which has a number of switches for options to control the output.

There are levels out publishing:

  1. Move the files and folders and pull in the nuget packages ready for deployment
  2. Same as above, but compile all the *.cs files into a dll

The KRE runtime can now run code without it having to be compiled first.  This enables deployment to be a simple xcopy of the source files. If you want to compile all the source files up front then rather than compiling them to a traditional bin folder they will get compiled into a nuget package and get deployed into the packages folder. This is an important point as it means that all executable C# code is modular and managed at the package level.

You starting folder structure will look similar to the below tree structure, this is the structure that would get checked-in to your source control provider.

  • $/
    • src
      • MyWebApp
        • project.json
        • files.cs
        • wwwroot
          • static files

All external nuget packages would be references under the dependencies node of your project.json file, however your packages are pulled down from the remote repository and stored in a local cache in your user profile. When your application runs the KRE runtime will probe for the packages and use the cached versions.

Packing the solution using kpm and the pack command will generate an xcopyable deployable.

kpm pack –out output file path

Output directory structure

  • output file path
    •  wwwroot
      • web.config
      • static files
    • approot
      • packages
        • nuget packages
      • src
        • project.json
        • x.cs

This separation of source code and static files means that code can never be served.

IIS or Kestrel anchors to the wwwroot folder.

If your decided to compile your application when you package the output folder structure would look similar to the below:

  • output file path
    •  wwwroot
      • web.config
      • static files
    • approot
      • packages
        • nuget packages
        • MyAppPackage

The MyAppPackage represents your source code compiled to a nuget package, the package process all pulls all cached versions of the dependent nuget packages so that they can be xcopy deployed.

Using wild cards in version numbers enables automatic updates to dependencies without having to reupdate

KRE – is the new runtime, this can be included in the packages folder if the CLR is not already installed on the target machine.

CLR can be either remote deployed onto a server and shared, or deployed locally within the packages folder which will take precedence.

F5 != kpm pack

The Visual Studio publish UI uses this underlying command.

 

 

Published in ASP.net

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *