Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add a file as a link in a .NET Core library?

I've added a .NET Core RC2 class lib to my solution (for fun) and the first thing I usually do is add a link to a shared GlobalAssemblyInfo.cs and edit the existing AssemblyInfo.cs down to the assembly specifics.

So I've just done "Add"->"existing item", located my file and clicked the dropdown of the add button. No "Add as Link" option.

What's the deal? How do I do this with .NET Core?

like image 378
Ian Avatar asked May 19 '16 20:05

Ian


People also ask

How do I add a reference to .NET Core library?

Add Class Library Reference To use a class library in your application, you must add a reference to the library to access its functionality. Right click on the project name of your console app in Solution Explorer and select Add ->Reference option.

How do I add a link to a file in Visual Studio?

To add a file as a link, right click and choose Add > Existing Item… as before, but this time, don't click the Add button. Instead, click the little dropdown arrow next to the Add button and select Add as Link. Instead of copying the file into the project directory, Visual Studio will create a link to the original.

How do I serve a static file in NET Core?

To serve static files from an ASP.NET Core app, you must configure static files middleware. With static files middleware configured, an ASP.NET Core app will serve all files located in a certain folder (typically /wwwroot).


1 Answers

I don’t think the tooling supports this yet, and unfortunately, the documentation is not up to date on this yet.

However, you can get an idea on how this works from this ASP.NET Core announcement. Basically, you can add individual file paths to the buildOptions.compile.includeFiles setting in your project.json:

{
    "buildOptions": {
        // …
        "compile": {
            // …
            "includeFiles": [
                // …
                "../shared/GlobalAssemblyInfo.cs"
            ]
         }
     }
}
like image 148
poke Avatar answered Oct 05 '22 09:10

poke