How to disable source code publishing in ASP.NET 5 apps?

1.9k views Asked by At

Here is how the deployed content looks like after publishing (on Azure Website):

/approot/packages              - NuGet packages
/approot/src                   - all the source files from the solution
/approot/global.json           - a list of global NuGet packages
/wwwroot/bin/AspNet.Loader.dll - the only .dll file in wwwroot folder
/wwwroot/css                   - front-end code
/wwwroot/lib                   - front-end code
/wwwroot/web.config            - auto-generated

web.config generated during publishing

I'm wondering, how to make it deploy only the compiled output and not the source files?

1

There are 1 answers

0
Kiran On
  • If you are publishing through VS 2015, then make the following selection to not deploy the source files: enter image description here

  • If you are not using VS, then you can use kpm pack command to achieve this. For example, following is the command that VS uses to create the package to deploy (You can enable Detailed logging in Tools | Options | Projects and Solutions | Build and Run, to see this)

    "C:\Users\kiranchalla\.kre\packages\kre-clr-x86.1.0.0-beta2-10690\bin\kpm.cmd" pack --runtime KRE-CLR-x86.1.0.0-beta2-10690 --out "C:\Users\kiranchalla\AppData\Local\Temp\AspNetPublish\WebApplication5-91" --wwwroot-out wwwroot --no-source --configuration Release --quiet

Some info:
The effect of the above is that now your application is pre-compiled and you should see a package under the packages folder and the kre-app-base flag in web.config points to this package. Example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="kpm-package-path" value="..\approot\packages" />
    <add key="bootstrapper-version" value="1.0.0-beta1" />
    <add key="kre-package-path" value="..\approot\packages" />
    <add key="kre-version" value="1.0.0-beta2-10690" />
    <add key="kre-clr" value="CLR" />
    <add key="kre-app-base" value="..\approot\packages\WebApplication5\1.0.0\root" />
  </appSettings>
</configuration>