question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unexpected/unnecessary `refs` directory in published output of ASP.NET Core application

See original GitHub issue

Steps to reproduce

  1. create new ASP.NET Core (.NET Framework) application template in Visual Studio
  2. publish a release build

Expected behavior

  • The only DLLs included local to the .exe would be third-party libraries loaded as nugget packages

Actual behavior

  • There is a refs directory that contains many System.* DLLs, a copy of the application, and the DLL for Razor Tooling
  • The refs directory can be removed and the application still runs and Razor pages still render

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
eerhardtcommented, Sep 26, 2016

If you don’t want this directory published, you can remove:

"preserveCompilationContext": true

from your project.json. But note that removing that setting may completely break your Razor compilation at runtime.

Closing as “by design”.

@pranavkm

1reaction
Neutrino-Sunsetcommented, Jan 19, 2017

I don’t understand what’s going on here.

“Razor compilation is attempting to use the same refs to compile the view at runtime as the ones that the application used.”

This suggests that there are two separate sets of dependencies.

  1. The application’s dependencies.
  2. The dependencies used by Razor to compile the view.

But isn’t the code compiling the view contained in the Microsoft.AspNetCore assemblies? And aren’t those assemblies loaded into the application’s app domain? So don’t they have the same dependencies as the application anyway, since they are part of the same application?

Also the assemblies in /refs don’t even look like the actual assemblies they purport to be. E.g. Microsoft.CSharp.dll in/refs is 23k, except that no real Micorsoft.CSharp.dll is actually 23k, the real ones are 1.1MB (Dotnet Core) and 472K (Dotnet Framework).

There is clearly more going on here than meets the eye and I need to understand it as I am designing our first ASP.Net Core application.

Is there a fuller more technical explanation of this somewhere or can someone here explain this please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

unexpected/unnecessary refs directory in published output ...
Steps to reproduce create new ASP.NET Core (.NET Framework) application template in Visual Studio publish a release build Expected behavior ...
Read more >
What is 'refs' folder in ASP.NET Core app's publish ...
If your Asp.Net Core application uses MVC, you would likely be using ... unexpected/unnecessary `refs` directory in published output of ASP.
Read more >
Refs folder not created during dotnet build
When I run dotnet publish , everything works fine. In particular, a refs folder is created in the published directory with the referenced...
Read more >
When publishing a web application using ...
AspNetCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program ... This result in the "refs" folder being published along with the app files.
Read more >
Administrator, Agricultural Marketing Service.
List of Subjects in 7 CFR Part 63 Administrative practice and procedure, ... EPA approved the applications and published a Federal Register ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found