Currently, it seems that the default behavior of a VS project is that NuGet-managed dependencies have intermediate files made by NuGet during a compile. Those files are these, in the obj folder:

I like being able to control the name of these output directories (as you can see with Binary and Object), and I'd like to setup my project such that the obj folder isn't used by NuGet to store these files. Is there a way to specify this at the project level or solution level? Maybe an MSBuild XML code snippet? Would be nice.
Any information would be appreciated.
Is there a way to specify this at the project level or solution level? Maybe an MSBuild XML code snippet? Would be nice.
If you want to change these nuget restore files in another folder, you can try to use Directly.Build.props file to control it.
Solution
1) create a file named Directly.Build.props in your project.

Then add these in this file:
<Project>
<PropertyGroup>
<MSBuildProjectExtensionsPath>$(ProjectDir)Binary\</MSBuildProjectExtensionsPath>
</PropertyGroup>
</Project>
Note: MSBuild Property can only be overwritten by another property. This means that you can overwrite the obj folder as a binary folder. If you want to generate two folders Binary and Object, you can try these:
a) When you try step 1 and then build your project, you can change the property to $(ProjectDir)Object\ in Directly.Build.propsfile and then rebuild again. After that, you will see both of them.
b) do a copy task and please write these in your xxxx.csproj file.
<Target Name="CopyNugetfiles" AfterTargets="Build">
<ItemGroup>
<MySourceFiles Include="$(ProjectDir)Binary\*.*"/>
</ItemGroup>
<Copy
SourceFiles="@(MySourceFiles)"
DestinationFolder="$(ProjectDir)Object\"/>
</Target>
Hope it could help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With