C
C#15mo ago
moon

❔ Help copying dependencies to output folder

Hey guys! I'm setting up some CI tools for myself and have run into the following issue: I use ILRepack to pack all my dependencies into my distributed plugin. As it stands, I expect them to be in the output folder. When I build my project from VS2022, all dependencies are copied to the output folder, as is standard practice for .NET Framework. However, if I build the same project with dotnet build (using .NET 7.0.4), that doesn't happen, and the usual method for doing so in .NET Standard / .NET Core / .NET 5+ (CopyLocalLockFileAssemblies) doesn't work because this is a .NET Framework project. I've explored upgrading my project to .NET Standard, and will do so if I have to, but in testing I hit some compatibility issues that I'm not confident I'd be able to iron out in my large (to me 02LUL ) project. I need to build with dotnet build for CI purposes, so... Either I bite the bullet and upgrade to .NET Standard 2.1 or find some way to locate dependency .dlls when building from dotnet build. Anyone got any insight, or willing to sanity check me? <:ChillBar_pray:872511920119377941>
17 Replies
Azrael
Azrael15mo ago
I might just be stupid, but what about MSBuild scripts?
moon
moonOP15mo ago
I promise I'm the stupid one 02LUL What did you have in mind? I'm not very familiar with msbuild scripts
Azrael
Azrael15mo ago
all dependencies are copied to the output folder, as is standard practice for .NET Framework.
<Target Name="MyCopyFilesToOutputDirectory">
<Copy SourceFiles="@(None)" DestinationFolder="$(OutDir)" />
</Target>
<Target Name="MyCopyFilesToOutputDirectory">
<Copy SourceFiles="@(None)" DestinationFolder="$(OutDir)" />
</Target>
Something like this right? You can specify DestinationFolder.
moon
moonOP15mo ago
Ah. Something like that, but I'm missing dependencies from nuget as well. If there's a way I could learn of their location in an msbuild script I'm game 02LUL
Azrael
Azrael15mo ago
Where are your NuGets located? Oh right, sorry.
moon
moonOP15mo ago
Not a clue, unfortunately rooderp Best info I can provide there is that I'm setting this up in github actions, so I'm relying on dotnet restore to restore them, and that's all I really know rooderp
Azrael
Azrael15mo ago
<ItemGroup>
<NunitPackage Include="$(PackagesDirectory)\NUnit.*\tools\nunit-console.exe"/>
</ItemGroup>

<Target Name="Test">
<CreateItem Include="$(BuildCompileDirectory)\*.Tests.*dll">
<Output TaskParameter="Include" ItemName="TestAssemblies" />
</CreateItem>
<NUnit
Assemblies="@(TestAssemblies)"
ToolPath="@(NunitPackage->'%(relativedir)')"
WorkingDirectory="$(BuildCompileDirectory)"
OutputXmlFile="$(BuildDirectory)\$(SolutionName).Tests.xml" />
</Target>
<ItemGroup>
<NunitPackage Include="$(PackagesDirectory)\NUnit.*\tools\nunit-console.exe"/>
</ItemGroup>

<Target Name="Test">
<CreateItem Include="$(BuildCompileDirectory)\*.Tests.*dll">
<Output TaskParameter="Include" ItemName="TestAssemblies" />
</CreateItem>
<NUnit
Assemblies="@(TestAssemblies)"
ToolPath="@(NunitPackage->'%(relativedir)')"
WorkingDirectory="$(BuildCompileDirectory)"
OutputXmlFile="$(BuildDirectory)\$(SolutionName).Tests.xml" />
</Target>
You can do something like this.
moon
moonOP15mo ago
Ahaaa, I seeee! I'll see what I can do with that aquaSalute02LUL
Azrael
Azrael15mo ago
Actually, you shouldn't use PackagesDirectory. It's a user defined macro.
moon
moonOP15mo ago
Oop never mind then 02LUL
Azrael
Azrael15mo ago
Use $(NuGetPackageRoot).
moon
moonOP15mo ago
NICE Thank you NekoLove
Azrael
Azrael15mo ago
Common NuGet configurations
NuGet.Config files control NuGet's behavior, and can be modified with nuget config command.
Azrael
Azrael15mo ago
This should be it.
moon
moonOP15mo ago
Many thanks 02LUL I'll poke around with it when I get home tonight
Azrael
Azrael15mo ago
👍
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server