Skip to content
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

Microsoft.AspNetCore.DataProtection.Abstractions higher version than referenced assembly #8527

Closed
pjmagee opened this issue Mar 14, 2019 · 6 comments

Comments

@pjmagee
Copy link

pjmagee commented Mar 14, 2019

Describe the bug

Cannot write tests for IDataProtectionProvider because Visual Studio thinks I'm referencing a higher version in my main library. (The versions only go up to 2.2.0)

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core '3.0.100-preview3-010431'
  2. Run this code 'Any class that injects IDataProtectionProvider'
  3. Create xunit testing library and try to Mock / Stub IDataProtectionProvider
  4. Both app and nunit project using netcoreapp3.0
  5. See compiler errors regarding version of Abstractions.

Expected behavior

That the compiler errors should just use the version the main library is using.

Unit Test Project

  <ItemGroup>
    <PackageReference Include="FluentAssertions" Version="5.6.0" />    
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.0.0-preview3.19153.1" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />    
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Vision.Web\Vision.Web.csproj" />
  </ItemGroup>

Main Project

 <ItemGroup>
    <PackageReference Include="Atlassian.Stash.Api" Version="3.1.20" />
    <PackageReference Include="Docker.Registry.DotNet" Version="1.0.10" />
    <PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />

    <PackageReference Include="Microsoft.AspNetCore.Components.Server" Version="3.0.0-preview3-19153-02" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview3-19153-02" />
    
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview3.19153.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.0.0-preview3.19153.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview3.19153.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0-preview3.19153.1" />
    
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.2" />
    <PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.172" />
    <PackageReference Include="NBuilder" Version="6.0.0" />
    <PackageReference Include="NSwag.AspNetCore" Version="12.0.15" />
  </ItemGroup>

Screenshots

inline

Additional context

The .NET Core website runs perfectly fine. Including the DataProtector library, I've checked my database and it's encrypting the data. However, I have to comment out any class that uses this because the test project wont compile.

Include the output of dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview3-010431
 Commit:    d72abce213

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\

Host (useful for support):
  Version: 3.0.0-preview3-27503-5
  Commit:  3844df9537

.NET Core SDKs installed:
  2.2.200 [C:\Program Files\dotnet\sdk]
  3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview3-27503-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview3-27504-2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
@pjmagee pjmagee changed the title Microsoft.AspNetCore.DataProtectionProvider.Abstractions Microsoft.AspNetCore.DataProtectionProvider.Abstractions higher version than referenced assembly Mar 14, 2019
@pjmagee pjmagee changed the title Microsoft.AspNetCore.DataProtectionProvider.Abstractions higher version than referenced assembly Microsoft.AspNetCore.DataProtection.Abstractions higher version than referenced assembly Mar 14, 2019
@Eilon
Copy link
Member

Eilon commented Mar 15, 2019

Mixing package versions of Microsoft.AspNetCore.* is not supported. Looks like the "Main Project" is referencing DataProtection 2.2. That will need to be updated to 3.0 as well.

@pjmagee
Copy link
Author

pjmagee commented Mar 15, 2019

Hi @Eilon , I could not find a 3.0 version, do i need to add a feed for this or is this something that will come at a later stage?

Thanks

@Eilon
Copy link
Member

Eilon commented Mar 15, 2019

Ah, you are right. That is one of the package that was moved into the ASP.NET "Shared framework." You can read more about that in the ASP.NET Core migration guide from 2.2 to 3.0: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-2.2&tabs=visual-studio

And there is some additional reference information here:

@pjmagee
Copy link
Author

pjmagee commented Mar 15, 2019

Thanks! I'll take a look at this in a few hours. Appreciate the help.

@pjmagee
Copy link
Author

pjmagee commented Mar 15, 2019

Fixed it with your help, now i reference <PackageReference Include="Microsoft.AspNetCore.App" Version="3.0.0-preview3-19153-02" /> in my unit tests and removed the <PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.2.0" /> from the 'Main project', since its already in the shared framework.

Closing this as now it compiles and i can run the tests.

@pjmagee pjmagee closed this as completed Mar 15, 2019
@Eilon
Copy link
Member

Eilon commented Mar 15, 2019

Awesome!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants