dotnet publish command produces output that contains refs folder. This folder contains the same core assemblies that I have in the root publish folder plus more. Also it contains one more copy of my .exe file. Without this folder the application throws an error about missing files.
I wonder, what is the purpose of this folder and why the same files have to be deployed twice increasing the deployment size?
@barynov -
The refs folder is only created if you set the preserveCompliationContext setting in your project.json file.
Here's what that setting controls:
https://github.com/dotnet/cli/blob/rel/1.0.0/src/Microsoft.DotNet.Compiler.Common/Executable.cs#L286
preserveCompilationContext stores metadata about references used to compile the application. The primary use case for this is Mvc which uses this to determine
• The list of assemblies that reference Mvc’s libraries during startup. This is used to filter assemblies that do not contain Mvc specific types such as controllers and view components.
• Used to figure out the list of assemblies required to perform runtime compilation of Razor views. The intent here is to compile specifically against the reference assemblies that were used in the compilation of the primary application. System.Web in the past used the set of loaded assemblies for compilation. A side effect of this was that the view could be compiling against newer APIs than the app targets (for instance when the app targets net451 but is running using net452).
Thank you for explanation.
@blackdwarf (is it too soon to ping @spboyer, too :smile: ) I wish this (and this type of information) were over at https://docs.microsoft.com/en-us/dotnet/articles/core/index (perhaps a branch point to a doc under the "Composition" heading) on how the :sparkles: magic :sparkles: works; however, I realize that a lot will change moving to MSBuild/csproj. Even if you considered such a doc, I can see why you would want to wait for a while.
@GuardRex exactly. This ✨ magic ✨ will be different when we move over to msbuild.
But the output still needs to be the same, right? The implementation will be different, but the results should be the same.
@eerhardt yes 1000% 😄
Most helpful comment
@blackdwarf (is it too soon to ping @spboyer, too :smile: ) I wish this (and this type of information) were over at https://docs.microsoft.com/en-us/dotnet/articles/core/index (perhaps a branch point to a doc under the "Composition" heading) on how the :sparkles: magic :sparkles: works; however, I realize that a lot will change moving to MSBuild/
csproj. Even if you considered such a doc, I can see why you would want to wait for a while.