0

Sometimes, when the nuget cache and intellisense break and neither dotnet restore nor nuget restore help, it's necessary to delete the obj folder in oder to rebuild the package information and fix all the false red flags.

In some projects, I cannot figure out when, after deleting obj (from inside VisualStudio) these elements are added to csproj:

  <ItemGroup>
    <_UnmanagedRegistrationCache Remove="obj\MyProject.csproj.UnmanagedRegistration.cache" />
  </ItemGroup>

  <ItemGroup>
    <_ResolveComReferenceCache Remove="obj\Debug\MyProject.csproj.ResolveComReference.cache" />
  </ItemGroup>

  <ItemGroup>
    <IntermediateAssembly Remove="obj\Debug\MyProject.dll" />
  </ItemGroup>

  <ItemGroup>
    <_DebugSymbolsIntermediatePath Remove="obj\Debug\MyProject.pdb" />
  </ItemGroup>

  <ItemGroup>
    <_DeploymentManifestEntryPoint Remove="obj\Debug\MyProject.dll" />
  </ItemGroup>

  <ItemGroup>
    <ApplicationManifest Remove="obj\Debug\Native.MyProject.manifest" />
  </ItemGroup>

  <ItemGroup>
    <DeployManifest Remove="obj\Debug\MyProject.application" />
  </ItemGroup>

I always remove them manually but it would be great if there was a way to prevent this from happening in the first place. Is that possible and how?

t3chb0t
  • 16,340
  • 13
  • 78
  • 118
  • Looks like you've got some problem with Excluded Globs: https://learn.microsoft.com/en-us/dotnet/core/tools/csproj#default-compilation-includes-in-net-core-projects – Jeremy Thompson Aug 28 '19 at 06:52
  • @JeremyThompson do you mean I somehow managed to do something to `msbuild` so that it doesn't automatically exclude `./obj` as it should (according to that link)? – t3chb0t Aug 28 '19 at 07:14
  • It's a long article, but no I wasn't referring to the paragraph below on the way msbuild see's it, just the paragraph I anchor linked. If you run ProcMon and reproduce it, is it devenv.exe or the NuGet that overwrites the csproj file? Also when ever I have to delete the obj folder I also delete the bin folder and the .suo file, does deleting all 3 still cause the issue? Also you're not doing anything funky with NuGet - why does the cache break? Is there some type library problem possibly caused by a mismatch of DLL versions (in one or two of the NuGet dependencies)? Does a Clean Solution fix ? – Jeremy Thompson Aug 28 '19 at 10:35
  • @JeremyThompson the package cache usually breaks when I pull a new version from a repository that updated some packages. VS has difficulties in restoring them. It's constantly showing exclamation marks and doesn't recognize many types in code that come via packages. I haven't tried to delete any other files or folders. I'll do this next time and see how this works. csproj, however, is updated virtually instantly. I hit obj delete and at the same moment the csproj is populated with that trash. – t3chb0t Aug 28 '19 at 10:41
  • 1
    I feel your pain: https://stackoverflow.com/a/55565841/495455 – Jeremy Thompson Aug 28 '19 at 12:51

0 Answers0