У меня возникают проблемы с проектом, ссылающимся на 2 пакета, которые затем ссылаются на Newtonsoft.Json, но оба в разных версиях. Я использую пакет nuget Refit
и Microsoft.NET.Sdk.Functions
. Когда я пытаюсь построить решение, я получаю следующую ошибку:
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet build
C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj : error NU1607: Version conflict detected for Newtonsoft.Json. Reference the package directly from the project to resolve this issue. \r
C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj : error NU1607: noddy.Api (>= 1.0.0) -> Refit (>= 4.0.1) -> Newtonsoft.Json (>= 10.0.3) \r
C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj : error NU1607: noddy.Api (>= 1.0.0) -> Microsoft.NET.Sdk.Functions (>= 1.0.2) -> Newtonsoft.Json (>= 9.0.1).
Теперь, если я сделаю то, что он говорит, и ссылается на пакет непосредственно из моего проекта, я получаю еще одну ошибку при создании:
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet add package Newtonsoft.Json
Writing C:\Users\joebloggs\AppData\Local\Temp\tmp7250.tmp
info : Adding PackageReference for package 'Newtonsoft.Json' into project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
log : Restoring packages for C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj...
info : CACHE http://www.myget.org/F/azure-appservice/api/v2/FindPackagesById()?id='Newtonsoft.Json'
info : CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json'
info : Package 'Newtonsoft.Json' is compatible with all the specified frameworks in project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
info : PackageReference for package 'Newtonsoft.Json' version '10.0.3' added to file 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
noddy.Api -> C:\dev\noddy\noddy-api\src\noddy.Api\bin\Debug\net461\bin\noddy.Api.dll
C:\Users\joebloggs\.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): error : Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified. [C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj]
Build FAILED.
C:\Users\joebloggs\.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): error : Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified. [C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:03.05
C:\dev\noddy\noddy-api\src\noddy.Api>
Я попытался добавить в перенаправление сборки, но кажется, что они игнорируются.
Я также попытался удалить все пакеты и добавить их обратно по одному и все равно без радости:
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet remove package refit
info : Removing PackageReference for package 'refit' from project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet remove package Microsoft.NET.Sdk.Functions
info : Removing PackageReference for package 'Microsoft.NET.Sdk.Functions' from project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet remove package Newtonsoft.Json
info : Removing PackageReference for package 'Newtonsoft.Json' from project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet add package Microsoft.NET.Sdk.Functions
Writing C:\Users\joebloggs\AppData\Local\Temp\tmp1F1B.tmp
info : Adding PackageReference for package 'Microsoft.NET.Sdk.Functions' into project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
log : Restoring packages for C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj...
info : CACHE http://www.myget.org/F/azure-appservice/api/v2/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'
info : CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'
info : Package 'Microsoft.NET.Sdk.Functions' is compatible with all the specified frameworks in project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
info : PackageReference for package 'Microsoft.NET.Sdk.Functions' version '1.0.2' added to file 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet add package refit
Writing C:\Users\joebloggs\AppData\Local\Temp\tmp39D7.tmp
info : Adding PackageReference for package 'refit' into project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
log : Restoring packages for C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj...
info : CACHE http://www.myget.org/F/azure-appservice/api/v2/FindPackagesById()?id='refit'
info : CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='refit'
error: Version conflict detected for Newtonsoft.Json. Reference the package directly from the project to resolve this issue.
error: noddy.Api (>= 1.0.0) -> Refit (>= 4.0.1) -> Newtonsoft.Json (>= 10.0.3)
error: noddy.Api (>= 1.0.0) -> Microsoft.NET.Sdk.Functions (>= 1.0.2) -> Newtonsoft.Json (>= 9.0.1).
info : Package 'refit' is compatible with all the specified frameworks in project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
info : PackageReference for package 'refit' version '4.0.1' added to file 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet build
C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj : error NU1607: Version conflict detected for Newtonsoft.Json. Reference the package directly from the project to resolve this issue. \r
C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj : error NU1607: noddy.Api (>= 1.0.0) -> Refit (>= 4.0.1) -> Newtonsoft.Json (>= 10.0.3) \r
C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj : error NU1607: noddy.Api (>= 1.0.0) -> Microsoft.NET.Sdk.Functions (>= 1.0.2) -> Newtonsoft.Json (>= 9.0.1).
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet add package Newtonsoft.Json
Writing C:\Users\joebloggs\AppData\Local\Temp\tmp8B13.tmp
info : Adding PackageReference for package 'Newtonsoft.Json' into project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
log : Restoring packages for C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj...
info : CACHE http://www.myget.org/F/azure-appservice/api/v2/FindPackagesById()?id='Newtonsoft.Json'
info : CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json'
info : Package 'Newtonsoft.Json' is compatible with all the specified frameworks in project 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
info : PackageReference for package 'Newtonsoft.Json' version '10.0.3' added to file 'C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj'.
C:\dev\noddy\noddy-api\src\noddy.Api>dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
noddy.Api -> C:\dev\noddy\noddy-api\src\noddy.Api\bin\Debug\net461\bin\noddy.Api.dll
C:\Users\joebloggs\.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): error : Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified. [C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj]
Build FAILED.
C:\Users\joebloggs\.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): error : Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified. [C:\dev\noddy\noddy-api\src\noddy.Api\noddy.Api.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:03.05
C:\dev\noddy\noddy-api\src\noddy.Api>
В моем csproj нет ничего волшебного:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="refit" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="proxies.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
У кого-нибудь есть идеи по устранению этой проблемы?