5
How can I refer dll’s in visual studio code?
I’m trying to compile a c# project with MVC architecture.
5
How can I refer dll’s in visual studio code?
I’m trying to compile a c# project with MVC architecture.
9
I found an extension that facilitates with the addition of Dlls. A .NET Core Add Reference is an extension that allows you to add a dll to your project. In the Extensions tab just search for this name above or click on the link, then just accept, that will open VS Code, then just install.
To use, press the Ctrl+shift+P keys and type or select Add Local. Net References and give , after that just paste the dll path you want to add to your project.
Detail,in this extension is not automated the update part of dll, so you need to clear the reference with dotnet nuget locals global-Packages --clear (this command clears all local references), add again the dll by Ctrl+shift+P, then type the dotnet command.
Source: https://cursos.alura.com.br/forum/topico-adicionar-referencia-de-dll-no-vscode-100552
7
Wouldn’t it just be adding the package via nuget? Link https://nuget.org/packages/NHibernate
dotnet add package NHibernate
Then run:
dotnet build
And if it’s all over
dotnet publish -c Release --self-contained
Now if it is an outside DLL even you could edit your file .csproj
and add (if your hypothetical dll is in the same project folder):
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<Reference Include="MyAssembly">
<HintPath>minha-dll.dll</HintPath>
</Reference>
</ItemGroup>
...
</Project>
You should also copy the DLL to the "build folders":
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<Reference Include="MyAssembly">
<HintPath>minha-dll.dll</HintPath>
</Reference>
</ItemGroup>
...
<Target Name="CustomAfterPublish" AfterTargets="AfterBuild">
<Message Text="ProjectDir: $(ProjectDir)" Importance="high" />
<Message Text="TargetDir: $(TargetDir)" Importance="high" />
<Copy SourceFiles="$(ProjectDir)minha-dll.dll" DestinationFolder="$(TargetDir)" />
<Copy SourceFiles="$(ProjectDir)minha-dll.dll" DestinationFolder="$(PublishDir)" />
</Target>
...
</Project>
But of course, if it is an "external" DLL in fact, for most cases it has no nuget and is only "compile".
In Vscode you do not need to run dotnet restore
, when downloading an existing project and if it is configured right just run in Run that everything will be installed automatically.
Usually Vscode suggests installing the extension for C#, but if you forgot to download:
Browser other questions tagged c# visual-studio-code dll
You are not signed in. Login or sign up in order to post.
You have opened in VS Coda only some file or folder alone, or opened it in VS Code whole project with all the project pastures?
– hugocsl
I believe this vscode plugin can help you https://marketplace.visualstudio.com/items?itemName=RafisTatar.addlocalnetreferences more information about the use you can find in this post: https://cursos.alura.com.br/forum/topico-adddll-no-vscode-100552
– NIZZOLA
I opened the whole protection and tried to run, as I came from the visual studio he lost all references
– Null
To those who are giving negative, please help me understand how I can improve the question, I was super objective, but it seems that not understand the subject is reason to negativate.
– Null
This project you created from scratch or downloaded via GIT or someone sent it to you and already contained the . csproj?
– Guilherme Nascimento
Only migrated from Visual Studio already containing the .csproj. Most dll’s are local.
– Null
@null ok but Nhibernate is a DLL or you installed via NUGET?
– Guilherme Nascimento