Compile .NET project with nuget packages Visual Studio

I want to create .DLL file out of dotnet project, but it uses some Nuget dependencies, which I would like to go to destination folder along with project's compiled DLL. How do I achieve that in Visual Studio?
8 Replies
Дядя Женя
Basically I want Arch.dll to be compiled and all the referenced dlls it has to also be in the output folder
jcotton42
jcotton426mo ago
how is this meant to be used? like, published to nuget? loaded as a plugin in another app? I think you just want dotnet publish though I don't remember if that works for library projects
Дядя Женя
I want to use it in Unity as managed dll plugin Unity fails to load Arch.dll because it cannot find any of it's dependencies, which are nuget packages
jcotton42
jcotton426mo ago
yeah, dotnet publish
Дядя Женя
and Unity wants every dependency .dll to also be inside the folder
jcotton42
jcotton426mo ago
or the publish option in Visual Studio if that shows up for library projects
Дядя Женя
seems like it worked, thank you very much
Petris
Petris6mo ago
If you'd want their PDBs and XML docs to be copied too, I can send a bit of MSBuild code for that tomorrow
<Target Name="CopyReferenceFilesBuild" BeforeTargets="Build">
<ItemGroup>
<ReferenceFiles Include="%(Reference.RelativeDir)%(Reference.Filename).xml;%(Reference.RelativeDir)%(Reference.Filename).pdb" Exclude="%(Reference.RelativeDir)netstandard.xml" />
</ItemGroup>
<Message Text="Copying reference files to $(OutputPath)" Importance="High" />
<Copy SourceFiles="@(ReferenceFiles)" DestinationFolder="$(OutputPath)" Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')" />
</Target>

<Target Name="CopyReferenceFilesPublish" BeforeTargets="Publish">
<ItemGroup>
<ReferenceFiles Include="%(Reference.RelativeDir)%(Reference.Filename).xml;%(Reference.RelativeDir)%(Reference.Filename).pdb" Exclude="%(Reference.RelativeDir)netstandard.xml" />
</ItemGroup>
<Message Text="Copying reference files to $(PublishDir)" Importance="High" />
<Copy SourceFiles="@(ReferenceFiles)" DestinationFolder="$(PublishDir)" Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')" />
</Target>
<Target Name="CopyReferenceFilesBuild" BeforeTargets="Build">
<ItemGroup>
<ReferenceFiles Include="%(Reference.RelativeDir)%(Reference.Filename).xml;%(Reference.RelativeDir)%(Reference.Filename).pdb" Exclude="%(Reference.RelativeDir)netstandard.xml" />
</ItemGroup>
<Message Text="Copying reference files to $(OutputPath)" Importance="High" />
<Copy SourceFiles="@(ReferenceFiles)" DestinationFolder="$(OutputPath)" Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')" />
</Target>

<Target Name="CopyReferenceFilesPublish" BeforeTargets="Publish">
<ItemGroup>
<ReferenceFiles Include="%(Reference.RelativeDir)%(Reference.Filename).xml;%(Reference.RelativeDir)%(Reference.Filename).pdb" Exclude="%(Reference.RelativeDir)netstandard.xml" />
</ItemGroup>
<Message Text="Copying reference files to $(PublishDir)" Importance="High" />
<Copy SourceFiles="@(ReferenceFiles)" DestinationFolder="$(PublishDir)" Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')" />
</Target>
if anybody wants it anyway
Want results from more Discord servers?
Add your server
More Posts
tetromino is phasing through my grid in unityits alot of stuff so i will just post a reddit link here where I put my infomation https://www.reddiHow to assign roles to already created Users in ASP.NET Identity?In ASP.NET I am trying to attribute Roles to specific users in my Database, I already have the users✅ how do I read a json file, edit it and save the edit in the json file?lets say we have a json file here: ```json { "meow" : 2 }``` 3 things Im wondering how to do(code bIs there a standard option to generate UUID version 7? (Guid)Hello, .NET provides a way to generate UUID v4 with `Guid.NewGuid()`, but this cannot be used as a What is the up-to-date version of AspNet.WebAPI?I am upgrading my console application to include Web Api, so i changed the sdk from `Microsoft.NET.S[WPF] How to edit multiple items in ListBox at onceI'm trying to edit multiple items using SelectionMode="Extended" to give the items a specific value,Please Help me. I spent 3 days trying to fix it to no avail.I am very new to coding and this is my first project. Trying to fix it but I couldnt manage it. httErrors while trying to build a VSA templatehttps://github.com/viceroypenguin/VsaTemplate/ I got errors while trying to build this templateSerialize value of property onlyGiven this code: https://dotnetfiddle.net/C3Pt3C How would I only serialize the value of the "TempTSometimes: Object Null Exception when using var rdr = await cmd.ExecuteReaderAsync();The cmd.ExecuteReaderAsync sometimes get NullException. Source: `public async Task<GetNavigationBar