2

I'm using VisualStudio 2019 CE and migrated my .Net project from packages.config to PackageReference.

Now is it possible to change the path of the generated obj folder?

Note: I'm not talking about <IntermediateOutputPath> tag in build file.

Yousha Aleayoub
  • 4,532
  • 4
  • 53
  • 64
  • Do you mean that you want to modify the location through PackageReference? The PackageReference just makes the whole package as reference in project. And as far as I know, there are no related configuration files for it. – Dylan Jul 29 '21 at 06:45
  • @DylanZhu-MSFT When we build the project, PackageReference generates a directory named `obj`. Next to the csproj build file. – Yousha Aleayoub Jul 29 '21 at 13:01
  • 1
    The obj folder is created by nuget.exe because the some target/props files of package needs to be placed into it. Maybe you can create a post build event, then use `move [src] [dist]` to [move it](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/move) or `rmdir /s /q $(ProjectDir)obj` to [remove it](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rmdir) – Dylan Jul 30 '21 at 10:05
  • @DylanZhu-MSFT thanks, but by doing that, NuGet references completely will be removed from the project. IDK why! My prefer way is to set a path for it like `` in my build file... – Yousha Aleayoub Jul 31 '21 at 09:37
  • Could you use [Directory.Build.targets](https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019) file with `` without modifying build file on your environment? – Dylan Aug 03 '21 at 09:57
  • The solution mentioned in this issue worked for me: https://stackoverflow.com/questions/63536867/completely-change-obj-folder-location-in-c-sharp-project – jasal Jun 30 '22 at 08:41

0 Answers0