Skip to content

dotnet restore fails to invalidate lock file and produce puzzling error messages #14198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
PetSerAl opened this issue Mar 21, 2025 · 1 comment
Labels
Area:RestoreRepeatableBuild The lock file features Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Product:dotnet.exe Type:Bug

Comments

@PetSerAl
Copy link

Directory.Packages.props:

<Project>
	<ItemGroup>
		<PackageVersion Include="DynamicData">
			<Version>9.2.1</Version>
		</PackageVersion>
		<PackageVersion Include="ReactiveUI">
			<Version>20.1.63</Version>
		</PackageVersion>
		<PackageVersion Include="Splat">
			<Version>15.3.1</Version>
		</PackageVersion>
	</ItemGroup>
</Project>

global.json:

{
	"sdk": {
		"version": "9.0.202"
	}
}

nuget.config:

<configuration>
	<config>
		<add key="globalPackagesFolder" value=".packages" />
	</config>
	<packageSources>
		<clear />
		<add key="nuget" value="https://api.nuget.org/v3/index.json" />
	</packageSources>
	<packageSourceMapping>
		<clear />
		<packageSource key="nuget">
			<package pattern="DynamicData" />
			<package pattern="ReactiveUI" />
			<package pattern="Splat" />
			<package pattern="System.ComponentModel.Annotations" />
			<package pattern="System.Reactive" />
		</packageSource>
	</packageSourceMapping>
</configuration>

nuget_restore.csproj:

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<CentralPackageTransitivePinningEnabled>True</CentralPackageTransitivePinningEnabled>
		<ManagePackageVersionsCentrally>True</ManagePackageVersionsCentrally>
		<RestorePackagesWithLockFile>True</RestorePackagesWithLockFile>
		<RuntimeFrameworkVersion>9.0.3</RuntimeFrameworkVersion>
		<TargetFramework>net9.0</TargetFramework>
	</PropertyGroup>
	<ItemGroup>
		<PackageReference Include="ReactiveUI" />
	</ItemGroup>
</Project>

Restore project:
Image

M:\Temp\nuget_restore>dotnet restore -terminalLogger:off -v n
Build started 20.03.2025 22:18:18.
     1>Project "M:\Temp\nuget_restore\nuget_restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for M:\Temp\nuget_restore\nuget_restore.csproj...
           GET https://api.nuget.org/v3-flatcontainer/reactiveui/index.json
           OK https://api.nuget.org/v3-flatcontainer/reactiveui/index.json 152ms
           GET https://api.nuget.org/v3-flatcontainer/reactiveui/20.1.63/reactiveui.20.1.63.nupkg
           OK https://api.nuget.org/v3-flatcontainer/reactiveui/20.1.63/reactiveui.20.1.63.nupkg 64ms
           GET https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/index.json
           OK https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/index.json 170ms
           GET https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/5.0.0/system.componentmodel.annotations.5.0.0.nupkg
           OK https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/5.0.0/system.componentmodel.annotations.5.0.0.nupkg 63ms
           GET https://api.nuget.org/v3-flatcontainer/dynamicdata/index.json
           OK https://api.nuget.org/v3-flatcontainer/dynamicdata/index.json 155ms
           GET https://api.nuget.org/v3-flatcontainer/dynamicdata/9.2.1/dynamicdata.9.2.1.nupkg
           OK https://api.nuget.org/v3-flatcontainer/dynamicdata/9.2.1/dynamicdata.9.2.1.nupkg 48ms
           GET https://api.nuget.org/v3-flatcontainer/system.reactive/index.json
           OK https://api.nuget.org/v3-flatcontainer/system.reactive/index.json 153ms
           GET https://api.nuget.org/v3-flatcontainer/system.reactive/6.0.1/system.reactive.6.0.1.nupkg
           OK https://api.nuget.org/v3-flatcontainer/system.reactive/6.0.1/system.reactive.6.0.1.nupkg 47ms
           GET https://api.nuget.org/v3-flatcontainer/splat/index.json
           OK https://api.nuget.org/v3-flatcontainer/splat/index.json 156ms
           GET https://api.nuget.org/v3-flatcontainer/splat/15.3.1/splat.15.3.1.nupkg
           OK https://api.nuget.org/v3-flatcontainer/splat/15.3.1/splat.15.3.1.nupkg 45ms
         Installed Splat 15.3.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\splat\15.3.1 with content hash zyu98Mwp8gTi3MlS6EGtvcacmw5W/qA4/h/DVeZ28A1dR6mcM628ujHck6LK5SM6LwroR5LzBonWgeFtwo2Afg==.
         Installed DynamicData 9.2.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\dynamicdata\9.2.1 with content hash 1Eh0D0emAwWB5wGDbT1VY1uttUpslrlkC/jVpw7/UnBfdMFhrq647rX5Ke7JDAm/a/4AoU/cLzPlcP3P3nfT+w==.
         Installed System.Reactive 6.0.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\system.reactive\6.0.1 with content hash rHaWtKDwCi9qJ3ObKo8LHPMuuwv33YbmQi7TcUK1C264V3MFnOr5Im7QgCTdLniztP3GJyeiSg5x8NqYJFqRmg==.
         Installed ReactiveUI 20.1.63 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\reactiveui\20.1.63 with content hash lPrrPDH5dgBZh/vpZGqycTbeRPHWcrLAhmRAOK8rqeAObVuYAzLrhoGusnfRvaljz0ApP5UiPLEdH7lxtfj0Jw==.
         Installed System.ComponentModel.Annotations 5.0.0 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\system.componentmodel.annotations\5.0.0 with content hash dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==.
           GET https://api.nuget.org/v3/vulnerabilities/index.json
           OK https://api.nuget.org/v3/vulnerabilities/index.json 160ms
           GET https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json
           GET https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json
           OK https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json 156ms
           OK https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json 345ms
         Generating MSBuild file M:\Temp\nuget_restore\obj\nuget_restore.csproj.nuget.g.props.
         Generating MSBuild file M:\Temp\nuget_restore\obj\nuget_restore.csproj.nuget.g.targets.
         Writing assets file to disk. Path: M:\Temp\nuget_restore\obj\project.assets.json
         Writing packages lock file at disk. Path: M:\Temp\nuget_restore\packages.lock.json
         Restored M:\Temp\nuget_restore\nuget_restore.csproj (in 4,79 sec).

         NuGet Config files used:
             M:\Temp\nuget_restore\NuGet.Config
             C:\Users\PetSerAl\AppData\Roaming\NuGet\NuGet.Config

         Feeds used:
             https://api.nuget.org/v3/index.json

         Installed:
             5 package(s) to M:\Temp\nuget_restore\nuget_restore.csproj
     1>Done Building Project "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:05.76

Bump ReactiveUI to 20.2.45: Directory.Packages.props:

<Project>
	<ItemGroup>
		<PackageVersion Include="DynamicData">
			<Version>9.2.1</Version>
		</PackageVersion>
		<PackageVersion Include="ReactiveUI">
			<Version>20.2.45</Version>
		</PackageVersion>
		<PackageVersion Include="Splat">
			<Version>15.3.1</Version>
		</PackageVersion>
	</ItemGroup>
</Project>

Restore project:
Image

M:\Temp\nuget_restore>dotnet restore -terminalLogger:off -v n
Build started 20.03.2025 22:33:26.
     1>Project "M:\Temp\nuget_restore\nuget_restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for M:\Temp\nuget_restore\nuget_restore.csproj...
           CACHE https://api.nuget.org/v3-flatcontainer/reactiveui/index.json
           GET https://api.nuget.org/v3-flatcontainer/reactiveui/20.2.45/reactiveui.20.2.45.nupkg
           OK https://api.nuget.org/v3-flatcontainer/reactiveui/20.2.45/reactiveui.20.2.45.nupkg 491ms
         Installed ReactiveUI 20.2.45 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\reactiveui\20.2.45 with content hash 1wyThKtWNi0naldJBYcKcZWib2POzS+fVX28apHGTAl+Gd5iLzoDSlItvC22Yiy+hc8TB7KnkW47kofuXmBhmg==.
     1>M:\Temp\nuget_restore\nuget_restore.csproj : error NU1100: Unable to resolve 'System.Text.Json (>= 9.0.2)' for 'net9.0'. PackageSourceMapping is enabled, the following source(s) were not considered: nuget.
           CACHE https://api.nuget.org/v3/vulnerabilities/index.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json
         Generating MSBuild file M:\Temp\nuget_restore\obj\nuget_restore.csproj.nuget.g.props.
         Writing assets file to disk. Path: M:\Temp\nuget_restore\obj\project.assets.json
         Writing packages lock file at disk. Path: M:\Temp\nuget_restore\packages.lock.json
         Failed to restore M:\Temp\nuget_restore\nuget_restore.csproj (in 2,09 sec).

         NuGet Config files used:
             M:\Temp\nuget_restore\NuGet.Config
             C:\Users\PetSerAl\AppData\Roaming\NuGet\NuGet.Config

         Feeds used:
             https://api.nuget.org/v3/index.json

         Installed:
             1 package(s) to M:\Temp\nuget_restore\nuget_restore.csproj
     1>Done Building Project "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

       "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target) (1) ->
       (Restore target) ->
         M:\Temp\nuget_restore\nuget_restore.csproj : error NU1100: Unable to resolve 'System.Text.Json (>= 9.0.2)' for 'net9.0'. PackageSourceMapping is enabled, the following source(s) were not considered: nuget.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:03.14

Allow System.Text.Json in PackageSourceMapping: nuget.config:

<configuration>
	<config>
		<add key="globalPackagesFolder" value=".packages" />
	</config>
	<packageSources>
		<clear />
		<add key="nuget" value="https://api.nuget.org/v3/index.json" />
	</packageSources>
	<packageSourceMapping>
		<clear />
		<packageSource key="nuget">
			<package pattern="DynamicData" />
			<package pattern="ReactiveUI" />
			<package pattern="Splat" />
			<package pattern="System.ComponentModel.Annotations" />
			<package pattern="System.Reactive" />
			<package pattern="System.Text.Json" />
		</packageSource>
	</packageSourceMapping>
</configuration>

Restore project:
Image

M:\Temp\nuget_restore>dotnet restore -terminalLogger:off -v n
Build started 20.03.2025 22:42:39.
     1>Project "M:\Temp\nuget_restore\nuget_restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for M:\Temp\nuget_restore\nuget_restore.csproj...
     1>M:\Temp\nuget_restore\nuget_restore.csproj : error NU1101: Unable to find package System.Text.Json. No packages exist with this id in source(s): nuget
           CACHE https://api.nuget.org/v3/vulnerabilities/index.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json
         Writing assets file to disk. Path: M:\Temp\nuget_restore\obj\project.assets.json
         Failed to restore M:\Temp\nuget_restore\nuget_restore.csproj (in 300 ms).

         NuGet Config files used:
             M:\Temp\nuget_restore\NuGet.Config
             C:\Users\PetSerAl\AppData\Roaming\NuGet\NuGet.Config

         Feeds used:
             https://api.nuget.org/v3/index.json
     1>Done Building Project "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

       "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target) (1) ->
       (Restore target) ->
         M:\Temp\nuget_restore\nuget_restore.csproj : error NU1101: Unable to find package System.Text.Json. No packages exist with this id in source(s): nuget

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.34

Cleanup and restore project:
Image

M:\Temp\nuget_restore>rd .packages /s /q & rd obj /s /q & dotnet restore -terminalLogger:off -v n
Build started 20.03.2025 22:47:40.
     1>Project "M:\Temp\nuget_restore\nuget_restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for M:\Temp\nuget_restore\nuget_restore.csproj...
           CACHE https://api.nuget.org/v3-flatcontainer/reactiveui/index.json
           CACHE https://api.nuget.org/v3-flatcontainer/reactiveui/20.2.45/reactiveui.20.2.45.nupkg
           CACHE https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/index.json
           CACHE https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/5.0.0/system.componentmodel.annotations.5.0.0.nupkg
           CACHE https://api.nuget.org/v3-flatcontainer/dynamicdata/index.json
           CACHE https://api.nuget.org/v3-flatcontainer/dynamicdata/9.2.1/dynamicdata.9.2.1.nupkg
           CACHE https://api.nuget.org/v3-flatcontainer/system.reactive/index.json
           CACHE https://api.nuget.org/v3-flatcontainer/system.reactive/6.0.1/system.reactive.6.0.1.nupkg
           CACHE https://api.nuget.org/v3-flatcontainer/splat/index.json
           CACHE https://api.nuget.org/v3-flatcontainer/splat/15.3.1/splat.15.3.1.nupkg
         Installed Splat 15.3.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\splat\15.3.1 with content hash zyu98Mwp8gTi3MlS6EGtvcacmw5W/qA4/h/DVeZ28A1dR6mcM628ujHck6LK5SM6LwroR5LzBonWgeFtwo2Afg==.
         Installed DynamicData 9.2.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\dynamicdata\9.2.1 with content hash 1Eh0D0emAwWB5wGDbT1VY1uttUpslrlkC/jVpw7/UnBfdMFhrq647rX5Ke7JDAm/a/4AoU/cLzPlcP3P3nfT+w==.
         Installed System.Reactive 6.0.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\system.reactive\6.0.1 with content hash rHaWtKDwCi9qJ3ObKo8LHPMuuwv33YbmQi7TcUK1C264V3MFnOr5Im7QgCTdLniztP3GJyeiSg5x8NqYJFqRmg==.
         Installed System.ComponentModel.Annotations 5.0.0 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\system.componentmodel.annotations\5.0.0 with content hash dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==.
         Installed ReactiveUI 20.2.45 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\reactiveui\20.2.45 with content hash 1wyThKtWNi0naldJBYcKcZWib2POzS+fVX28apHGTAl+Gd5iLzoDSlItvC22Yiy+hc8TB7KnkW47kofuXmBhmg==.
           GET https://api.nuget.org/v3-flatcontainer/system.text.json/index.json
           OK https://api.nuget.org/v3-flatcontainer/system.text.json/index.json 527ms
     1>M:\Temp\nuget_restore\nuget_restore.csproj : error NU1102: Unable to find package System.Text.Json with version (>= 9.0.2)
       M:\Temp\nuget_restore\nuget_restore.csproj : error NU1102:   - Found 135 version(s) in nuget [ Nearest version: 9.0.2 ]
           CACHE https://api.nuget.org/v3/vulnerabilities/index.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json
         Generating MSBuild file M:\Temp\nuget_restore\obj\nuget_restore.csproj.nuget.g.props.
         Generating MSBuild file M:\Temp\nuget_restore\obj\nuget_restore.csproj.nuget.g.targets.
         Writing assets file to disk. Path: M:\Temp\nuget_restore\obj\project.assets.json
         Failed to restore M:\Temp\nuget_restore\nuget_restore.csproj (in 1,58 sec).

         NuGet Config files used:
             M:\Temp\nuget_restore\NuGet.Config
             C:\Users\PetSerAl\AppData\Roaming\NuGet\NuGet.Config

         Feeds used:
             https://api.nuget.org/v3/index.json

         Installed:
             5 package(s) to M:\Temp\nuget_restore\nuget_restore.csproj
     1>Done Building Project "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

       "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target) (1) ->
       (Restore target) ->
         M:\Temp\nuget_restore\nuget_restore.csproj : error NU1102: Unable to find package System.Text.Json with version (>= 9.0.2)
       M:\Temp\nuget_restore\nuget_restore.csproj : error NU1102:   - Found 135 version(s) in nuget [ Nearest version: 9.0.2 ]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.66

Bump System.Text.Json to 9.0.3: Directory.Packages.props:

<Project>
	<ItemGroup>
		<PackageVersion Include="DynamicData">
			<Version>9.2.1</Version>
		</PackageVersion>
		<PackageVersion Include="ReactiveUI">
			<Version>20.2.45</Version>
		</PackageVersion>
		<PackageVersion Include="Splat">
			<Version>15.3.1</Version>
		</PackageVersion>
		<PackageVersion Include="System.Text.Json">
			<Version>9.0.3</Version>
		</PackageVersion>
	</ItemGroup>
</Project>

Restore project:
Image

M:\Temp\nuget_restore>dotnet restore -terminalLogger:off -v n
Build started 20.03.2025 22:53:44.
     1>Project "M:\Temp\nuget_restore\nuget_restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for M:\Temp\nuget_restore\nuget_restore.csproj...
     1>M:\Temp\nuget_restore\nuget_restore.csproj : error NU1101: Unable to find package System.Text.Json. No packages exist with this id in source(s): nuget
           GET https://api.nuget.org/v3/vulnerabilities/index.json
           OK https://api.nuget.org/v3/vulnerabilities/index.json 160ms
           GET https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json
           GET https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json
           OK https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json 159ms
           OK https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json 244ms
     1>C:\Program Files\dotnet\sdk\9.0.202\NuGet.targets(175,5): error : The given key 'System.Text.Json' was not present in the dictionary. [M:\Temp\nuget_restore\nuget_restore.csproj]
     1>Done Building Project "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

       "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target) (1) ->
       (Restore target) ->
         M:\Temp\nuget_restore\nuget_restore.csproj : error NU1101: Unable to find package System.Text.Json. No packages exist with this id in source(s): nuget
         C:\Program Files\dotnet\sdk\9.0.202\NuGet.targets(175,5): error : The given key 'System.Text.Json' was not present in the dictionary. [M:\Temp\nuget_restore\nuget_restore.csproj]

    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:02.36

Cleanup and restore project:
Image

M:\Temp\nuget_restore>rd .packages /s /q & rd obj /s /q & dotnet restore -terminalLogger:off -v n
Build started 20.03.2025 22:56:27.
     1>Project "M:\Temp\nuget_restore\nuget_restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for M:\Temp\nuget_restore\nuget_restore.csproj...
           GET https://api.nuget.org/v3-flatcontainer/reactiveui/index.json
           OK https://api.nuget.org/v3-flatcontainer/reactiveui/index.json 186ms
           CACHE https://api.nuget.org/v3-flatcontainer/reactiveui/20.2.45/reactiveui.20.2.45.nupkg
           GET https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/index.json
           OK https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/index.json 147ms
           GET https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/5.0.0/system.componentmodel.annotations.5.0.0.nupkg
           OK https://api.nuget.org/v3-flatcontainer/system.componentmodel.annotations/5.0.0/system.componentmodel.annotations.5.0.0.nupkg 64ms
           GET https://api.nuget.org/v3-flatcontainer/dynamicdata/index.json
           OK https://api.nuget.org/v3-flatcontainer/dynamicdata/index.json 150ms
           GET https://api.nuget.org/v3-flatcontainer/dynamicdata/9.2.1/dynamicdata.9.2.1.nupkg
           OK https://api.nuget.org/v3-flatcontainer/dynamicdata/9.2.1/dynamicdata.9.2.1.nupkg 52ms
           GET https://api.nuget.org/v3-flatcontainer/system.reactive/index.json
           OK https://api.nuget.org/v3-flatcontainer/system.reactive/index.json 148ms
           GET https://api.nuget.org/v3-flatcontainer/system.reactive/6.0.1/system.reactive.6.0.1.nupkg
           OK https://api.nuget.org/v3-flatcontainer/system.reactive/6.0.1/system.reactive.6.0.1.nupkg 48ms
           GET https://api.nuget.org/v3-flatcontainer/splat/index.json
           OK https://api.nuget.org/v3-flatcontainer/splat/index.json 143ms
           GET https://api.nuget.org/v3-flatcontainer/splat/15.3.1/splat.15.3.1.nupkg
           OK https://api.nuget.org/v3-flatcontainer/splat/15.3.1/splat.15.3.1.nupkg 80ms
         Installed Splat 15.3.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\splat\15.3.1 with content hash zyu98Mwp8gTi3MlS6EGtvcacmw5W/qA4/h/DVeZ28A1dR6mcM628ujHck6LK5SM6LwroR5LzBonWgeFtwo2Afg==.
         Installed DynamicData 9.2.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\dynamicdata\9.2.1 with content hash 1Eh0D0emAwWB5wGDbT1VY1uttUpslrlkC/jVpw7/UnBfdMFhrq647rX5Ke7JDAm/a/4AoU/cLzPlcP3P3nfT+w==.
         Installed System.Reactive 6.0.1 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\system.reactive\6.0.1 with content hash rHaWtKDwCi9qJ3ObKo8LHPMuuwv33YbmQi7TcUK1C264V3MFnOr5Im7QgCTdLniztP3GJyeiSg5x8NqYJFqRmg==.
         Installed System.ComponentModel.Annotations 5.0.0 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\system.componentmodel.annotations\5.0.0 with content hash dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==.
         Installed ReactiveUI 20.2.45 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\reactiveui\20.2.45 with content hash 1wyThKtWNi0naldJBYcKcZWib2POzS+fVX28apHGTAl+Gd5iLzoDSlItvC22Yiy+hc8TB7KnkW47kofuXmBhmg==.
           CACHE https://api.nuget.org/v3-flatcontainer/system.text.json/index.json
     1>M:\Temp\nuget_restore\nuget_restore.csproj : error NU1102: Unable to find package System.Text.Json with version (>= 9.0.3)
       M:\Temp\nuget_restore\nuget_restore.csproj : error NU1102:   - Found 135 version(s) in nuget [ Nearest version: 9.0.3 ]
           CACHE https://api.nuget.org/v3/vulnerabilities/index.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json
     1>C:\Program Files\dotnet\sdk\9.0.202\NuGet.targets(175,5): error : The given key 'System.Text.Json' was not present in the dictionary. [M:\Temp\nuget_restore\nuget_restore.csproj]
     1>Done Building Project "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target(s)) -- FAILED.

Build FAILED.

       "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target) (1) ->
       (Restore target) ->
         M:\Temp\nuget_restore\nuget_restore.csproj : error NU1102: Unable to find package System.Text.Json with version (>= 9.0.3)
       M:\Temp\nuget_restore\nuget_restore.csproj : error NU1102:   - Found 135 version(s) in nuget [ Nearest version: 9.0.3 ]
         C:\Program Files\dotnet\sdk\9.0.202\NuGet.targets(175,5): error : The given key 'System.Text.Json' was not present in the dictionary. [M:\Temp\nuget_restore\nuget_restore.csproj]

    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:04.51

Remove lock file and restore project:
Image

M:\Temp\nuget_restore>del packages.lock.json & dotnet restore -terminalLogger:off -v n
Build started 20.03.2025 23:01:25.
     1>Project "M:\Temp\nuget_restore\nuget_restore.csproj" on node 1 (Restore target(s)).
     1>_GetAllRestoreProjectPathItems:
         Determining projects to restore...
       Restore:
         X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
         X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
         Restoring packages for M:\Temp\nuget_restore\nuget_restore.csproj...
           CACHE https://api.nuget.org/v3-flatcontainer/system.text.json/index.json
           GET https://api.nuget.org/v3-flatcontainer/system.text.json/9.0.3/system.text.json.9.0.3.nupkg
           OK https://api.nuget.org/v3-flatcontainer/system.text.json/9.0.3/system.text.json.9.0.3.nupkg 589ms
         Installed System.Text.Json 9.0.3 from https://api.nuget.org/v3/index.json to M:\Temp\nuget_restore\.packages\system.text.json\9.0.3 with content hash r2JRkLjsYrq5Dpo7+y3Wa73OfirZPdVhxiTJWwZ+oJM7FOAe0LkM3GlH+pgkNRdd1G1kwUbmRCdmh4uoaWwu1g==.
           CACHE https://api.nuget.org/v3/vulnerabilities/index.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/vulnerability.base.json
           CACHE https://api.nuget.org/v3-vulnerabilities/2025.03.12.23.21.10/2025.03.20.17.21.44/vulnerability.update.json
         Generating MSBuild file M:\Temp\nuget_restore\obj\nuget_restore.csproj.nuget.g.props.
         Generating MSBuild file M:\Temp\nuget_restore\obj\nuget_restore.csproj.nuget.g.targets.
         Writing assets file to disk. Path: M:\Temp\nuget_restore\obj\project.assets.json
         Writing packages lock file at disk. Path: M:\Temp\nuget_restore\packages.lock.json
         Restored M:\Temp\nuget_restore\nuget_restore.csproj (in 1,95 sec).

         NuGet Config files used:
             M:\Temp\nuget_restore\NuGet.Config
             C:\Users\PetSerAl\AppData\Roaming\NuGet\NuGet.Config

         Feeds used:
             https://api.nuget.org/v3/index.json

         Installed:
             1 package(s) to M:\Temp\nuget_restore\nuget_restore.csproj
     1>Done Building Project "M:\Temp\nuget_restore\nuget_restore.csproj" (Restore target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.97

As I understand, what is happened here:

First failed restore (one that error out because System.Text.Json was not added to PackageSourceMapping), regardless of error, still update content of lock file. Any following restores with that lock file, thinks that that lock file is current to the project, as no versions of packages in the project was updated, compared to lock file. That make dotnet restore to skip building dependency graph, and instead read it from lock file. Which force dotnet restore to repeat the failure of not able to resolve System.Text.Json package. Lock file, that represent failed restore, shoud not be considered to be current to project.

Issue is missing Type label, remember to add a Type label

@microsoft-github-policy-service microsoft-github-policy-service bot added the missing-required-type The required type label is missing. label Mar 22, 2025
@nkolev92 nkolev92 added Triage:Untriaged Type:Bug Product:dotnet.exe Area:RestoreRepeatableBuild The lock file features and removed missing-required-type The required type label is missing. labels Mar 24, 2025
@nkolev92 nkolev92 added Priority:2 Issues for the current backlog. Functionality:Restore Category:Quality Week Issues that should be considered for quality week labels Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreRepeatableBuild The lock file features Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Product:dotnet.exe Type:Bug
Projects
None yet
Development

No branches or pull requests

3 participants