Skip to content

Clearing NuGet package local cache breaks re-compiling file-based apps #51597

@gorban

Description

@gorban

Describe the bug

Clearing local NuGet package cache breaks re-compiling file-based apps.

To Reproduce

  1. Add NuGet package source (at least until 10.0.1 packages exist on nuget.org):
    dotnet nuget add source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json -n dotnet10
  2. Create a whatever.cs file with execute (chmod +x whatever.cs) with below contents.
  3. Execute it to compile and run the first time:
    ./whatever.cs
  4. Clear NuGet package local cache:
    dotnet nuget locals all -c
  5. At this point, executing ./whatever.cs still works fine (cached binary)
  6. Make any slight tweak to the code, e.g. the string passed to WriteLine: Console.WriteLine("I broke it!");
  7. Now, trying to rebuild / execute will fail:
    ./whatever.cs

Error:

error CS0006: Metadata file '/Users/bruck/.nuget/packages/microsoft.net.illink.tasks/10.0.0-rtm.25513.102/analyzers/dotnet/cs/ILLink.CodeFixProvider.dll' could not be found
error CS0006: Metadata file '/Users/bruck/.nuget/packages/microsoft.net.illink.tasks/10.0.0-rtm.25513.102/analyzers/dotnet/cs/ILLink.RoslynAnalyzer.dll' could not be found

The build failed. Fix the build errors and run again.

Code:

#!/usr/bin/env dotnet
#:property TargetFramework=net10.0
#:property RuntimeFrameworkVersion=10.0.0-rtm.25513.102
Console.WriteLine("Hello from a .NET script!");

Exceptions (if any)

Further technical details

.NET SDK:
Version: 10.0.101
Commit: e17b0d08de
Workload version: 10.0.100-manifests.c57ac48b
MSBuild version: 18.0.3+e17b0d08d

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.7
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/10.0.101/

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.1
Architecture: arm64
Commit: e17b0d08de

.NET SDKs installed:
8.0.407 [/usr/local/share/dotnet/sdk]
8.0.411 [/usr/local/share/dotnet/sdk]
10.0.101 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.17 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Metadata

Metadata

Labels

Area-run-fileItems related to the "dotnet run <file>" effort

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions