1

I'm running into a conflict when trying to include both of the following packages in a project:

<PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />

or by using:

<PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.0" />
<FrameworkReference Include="Microsoft.AspNetCore.OpenApi"/>

When I build the project, I get this error:

dotnet build
Restore complete (0.2s)
  MyApi net10.0 failed with 1 error(s) (0.0s)
    C:\Program Files\dotnet\sdk\10.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(40,5): error MSB4018:
      The "ResolvePackageFileConflicts" task failed unexpectedly.
      System.FormatException: Input string was not in a correct format. Failure to
      parse near offset 103. Expected an ASCII digit.
         at System.Text.ValueStringBuilder.AppendFormatHelper(IFormatProvider provi
      der, String format, ReadOnlySpan`1 args)
         at System.String.FormatHelper(IFormatProvider provider, String format, Rea
      dOnlySpan`1 args)
         at Microsoft.NET.Build.Tasks.Logger.CreateMessage(MessageLevel level, Stri
      ng format, String[] args)
         at Microsoft.NET.Build.Tasks.Logger.LogMessage(MessageImportance importanc
      e, String format, String[] args)
         at Microsoft.NET.Build.Tasks.ConflictResolution.ConflictResolver`1.Resolve
      Conflict(TConflictItem item1, TConflictItem item2, Boolean logUnresolvedConfl
      icts)
         at Microsoft.NET.Build.Tasks.ConflictResolution.ConflictResolver`1.Resolve
      Conflicts(IEnumerable`1 conflictItems, Func`2 getItemKey, ConflictCallback`1
      foundConflict, Boolean commitWinner)
         at Microsoft.NET.Build.Tasks.ConflictResolution.ResolvePackageFileConflict
      s.ExecuteCore()
         at Microsoft.NET.Build.Tasks.TaskBase.Execute()
         at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
         at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecuti
      onHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost tas
      kHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

Build failed with 1 error(s) in 0.5s

The error randomly appeared when I was renaming my models and their fields in my Web API project that uses Entity Framework Core. Even after reverting those changes or even completely removing the models the error did not go away.

What I've tried

I created a clean project only with these packages and I still get the error:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
    <PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.0" />
  </ItemGroup>
</Project>

I've tried:

  • Testing different package versions (9.0.9, 9.0.11, 10.0.0);
  • Using different SDK versions (9.0.305, 9.0.307, 10.0.100)
  • Clearing all NuGet and .NET caches;
  • Completely reinstalling .NET, NuGet and removing VS;
  • Running the project on another machine (works fine there).

The project builds fine if only one of these packages is included, but fails when both are present.

Does anyone have any ideas on how to fix this?

12
  • Have you tried checking out the project (assuming you use git) into another folder? Commented Nov 23 at 19:10
  • @GuruStron Yes I did. This also didn't work Commented Nov 23 at 20:04
  • Well the problem right now isn't the packages directly but something in MSBuild failing to generate a log message for some sort of package conflict. The System.FormatException: Input string was not in a correct format. Failure to parse near offset 103. Expected an ASCII digit.makes me curious. Is your code located in a path with some unexpected non-ascii chars perhaps? What if you just put it in C:\MyProject or something? Commented Nov 24 at 6:06
  • 1
    I created a console app on .NET 10 and added these packages and it compiles just fine, so there is something else going on not directly related to those packages. Commented Nov 24 at 6:07
  • Do you have $ or % sign somewhere in the path? Commented Nov 24 at 9:58

1 Answer 1

0

The .NET SDK currently has a bug where any { in a file's path (either file name or a directory name) will cause some builds to fail with the error reported in the question.

Until it is fixed, you can work around the issue by:

  1. Set the NUGET_PACKAGES environment variable to a path that does not contain any { characters. It's also possible to set the globalPackagesFolder setting in a nuget.config. Choose one that you prefer.
  2. Similarly, put all your code (projects, solutions, etc) in a path that does not contain any { characters.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.