-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
dotnet run --file a.cs oddly failed several times for me today, claiming the .csproj project file could not be loaded. But of course, there is no such project file. No clue why it's complaining.
But interestingly, adding -bl to the dotnet run command (which I hoped would shed light on the problem) just makes the problem disappear.
Another workaround is to add --no-cache.
To Reproduce
Notice these 2 commands, first fails, the second succeeds. The only difference: the -bl switch.
PS E:\VS\src\Shared\Tools\Scripts> dotnet run --file .\FindCodeAnalysisWarningEventArgs.cs
E:\VS\src\Shared\Tools\Scripts\FindCodeAnalysisWarningEventArgs.csproj : error MSB4025: The project file could not be loaded. Could not find file 'E:\VS\src\Shared\Tools\Scripts\FindCodeAnalysisWarningEventArgs.csproj'.
E:\VS\src\Shared\Tools\Scripts\FindCodeAnalysisWarningEventArgs.csproj : warning NU1503: Skipping restore for project 'E:\VS\src\Shared\Tools\Scripts\FindCodeAnalysisWarningEventArgs.csproj'. The project file may be invalid or missing targets required for restore.
C:\Program Files\dotnet\sdk\10.0.102\NuGet.targets(196,5): warning Unable to find a project to restore!
The build failed. Fix the build errors and run again.
PS E:\VS\src\Shared\Tools\Scripts> dotnet run --file .\FindCodeAnalysisWarningEventArgs.cs -bl
E:\VS\src\Shared\Tools\Scripts\FindCodeAnalysisWarningEventArgs.cs(99,24): warning IL2026: Using member 'System.Reflection.Assembly.LoadFrom(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed.
E:\VS\src\Shared\Tools\Scripts\FindCodeAnalysisWarningEventArgs.cs(101,30): warning IL2026: Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed.
Usage: dotnet FindCodeAnalysisWarningEventArgs.cs -- <path-to-binlog>
Further technical details
details of dotnet --info
.NET SDK: Version: 10.0.102 Commit: 4452502459 Workload version: 10.0.101.1 MSBuild version: 18.0.7+445250245
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.102\
.NET workloads installed:
[android]
Installation Source: SDK 10.0.100, VS 18.4.11427.29, VS 18.4.11426.133
Manifest Version: 36.1.2/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.sdk.android\36.1.2\WorkloadManifest.json
Install Type: Msi
[ios]
Installation Source: SDK 10.0.100, VS 18.4.11427.29, VS 18.4.11426.133
Manifest Version: 26.2.10191/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.sdk.ios\26.2.10191\WorkloadManifest.json
Install Type: Msi
[maccatalyst]
Installation Source: SDK 10.0.100, VS 18.4.11427.29, VS 18.4.11426.133
Manifest Version: 26.2.10191/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.sdk.maccatalyst\26.2.10191\WorkloadManifest.json
Install Type: Msi
[maui-windows]
Installation Source: SDK 10.0.100, VS 18.4.11427.29, VS 18.4.11426.133
Manifest Version: 10.0.1/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.sdk.maui\10.0.1\WorkloadManifest.json
Install Type: Msi
Configured to use workload sets when installing new manifests.
Host:
Version: 10.0.2
Architecture: x64
Commit: 4452502459
.NET SDKs installed:
9.0.205 [C:\Program Files\dotnet\sdk]
9.0.309 [C:\Program Files\dotnet\sdk]
9.0.310 [C:\Program Files\dotnet\sdk]
10.0.102 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
DOTNET_CLI_DISABLE_PUBLISH_AND_PACK_RELEASE [true]
DOTNET_SUGGEST_SCRIPT_VERSION [1.0.2]
global.json file:
E:\VS\global.json
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
This is at the CLI