Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 688
Konstantin Tarkus Avatar asked Nov 14 '14 13:11

Konstantin Tarkus


1 Answers

  • 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>
like image 101
Kiran Avatar answered Sep 19 '22 11:09

Kiran