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

.Net Core 2.0.0-preview1-final Nuget cannot be installed on .Net Standard 2.0 class library #700

Closed
Ponant opened this issue Jun 21, 2017 · 18 comments

Comments

@Ponant
Copy link

Ponant commented Jun 21, 2017

I have a class library created with VS 2017 and .Net Core Preview 1 and targeting .Net Standard 2.0 and it has the following NuGets in addition to the standard library

Microsoft.AspNetCore.Antiforgery v1.1.2
Microsoft.AspNetCore.Localization v1.1.2

Both cannot be upgraded to .Net Core 2.0.0-preview1-final and I receive as VS output
Package Microsoft.AspNetCore.Antiforgery 2.0.0-preview1-final is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package Microsoft.AspNetCore.Antiforgery 2.0.0-preview1-final supports: netcoreapp2.0 (.NETCoreApp,Version=v2.0)

The problem is that I have a web app using Microsoft.AspNetCore.Antiforgery 2.0.0-preview1-final
and referencing my library. This results in
TypeLoadException: Could not load type 'Microsoft.AspNetCore.Antiforgery.Internal.CryptographyAlgorithms' from assembly 'Microsoft.AspNetCore.Antiforgery, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Is this expected and is there a workaround?
To make it work so far I had to copy/paste the raw code from CryptographyAlgorithms directly into my class library, but that is obviously not the best thing to do.

@Petermarcu
Copy link
Member

This is because in Preview1 of ASP.NET Core 2.0, didn't support .NET Standard because it used API's that weren't available. In Preview2, I believe it will.

/cc @davidfowl @DamianEdwards

@Ponant
Copy link
Author

Ponant commented Jun 28, 2017

@Petermarcu , I think it is still not in preview 2...

@Petermarcu
Copy link
Member

In Preview2 ASP.NET moved back to .NET Standard. I'm not sure if there were specific libraries that couldn't. @DamianEdwards do you know?

@Ponant
Copy link
Author

Ponant commented Jun 29, 2017

@Ponant
Copy link
Author

Ponant commented Jun 29, 2017

Antigforgery 2.0.0-preview2-final does not recognize yet Microsoft.AspNetCore.Antiforgery.Internal.CryptographyAlgorithms

@Petermarcu
Copy link
Member

I don't know much about those packages. @DamianEdwards do you?

@davidfowl
Copy link
Member

@Ponant do you have a minimal repro that you can post to GitHub?

@Ponant
Copy link
Author

Ponant commented Jul 4, 2017

@davidfowl , I need to strip out my project; give me some time.

@Ponant
Copy link
Author

Ponant commented Jul 4, 2017

@davidfowl , see class1, CryptographyAlgorithms is not recognized.
https://github.com/Ponant/AntiforgeryCryptoInternalCore20Preview2

@davidfowl
Copy link
Member

@Ponant Where's the project that fails? Can you write some instructions on how to reproduce the problem?

@Ponant
Copy link
Author

Ponant commented Jul 4, 2017

If you open the project and goto class1.cs, you should see the CultureCryptoService class that CryptographyAlgorithms "does not exist in the current context". Whereas I installed the preview 2 antiforgery nuget.

@Ponant
Copy link
Author

Ponant commented Jul 4, 2017

antiforgerypreview2cryptobug

@davidfowl
Copy link
Member

@Ponant the project you put on github doesn't have any package references:

https://github.com/Ponant/AntiforgeryCryptoInternalCore20Preview2/blob/100d00de42077180be7a7afc1d1526321ddc0991/AntiforgeryCryptoInternalCore20Preview2/AntiforgeryCryptoInternalCore20Preview2/AntiforgeryCryptoInternalCore20Preview2.csproj

I'm still not clear on what you're expecting. Did you mean to add some package reference?

@Ponant
Copy link
Author

Ponant commented Jul 4, 2017

OH that is strange, probably an upload issue. Here is my csproj on my desktop

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.0.0-preview2-final" />
  </ItemGroup>

</Project>

@Ponant
Copy link
Author

Ponant commented Jul 4, 2017

@davidfowl , to answer your question, what I expect is CryptographyAlgorithms.cs to be public.
https://raw.githubusercontent.com/aspnet/Antiforgery/master/src/Microsoft.AspNetCore.Antiforgery/Internal/CryptographyAlgorithms.cs

@davidfowl
Copy link
Member

davidfowl commented Jul 4, 2017

That type isn't in the preview2 version of the Microsoft.AspNetCore.Antiforgery package. That's why it's not resolving.

It was in 1.1.x -
https://github.com/aspnet/Antiforgery/tree/rel/1.1.0/src/Microsoft.AspNetCore.Antiforgery/Internal

It's missing from preview2 - https://github.com/aspnet/Antiforgery/tree/rel/2.0.0-preview2/src/Microsoft.AspNetCore.Antiforgery/Internal

It's back in dev - https://github.com/aspnet/Antiforgery/tree/f292fa8db5fbf89ab80eaff7f4c8a469fbe6813b/src/Microsoft.AspNetCore.Antiforgery/Internal

These types are what we call "pubternal" they're not real public API, so they can go missing from version to version that's why they are in an "internal" namespace. However, they can be useful if you're on a particular version of the framework.

@Ponant
Copy link
Author

Ponant commented Jul 4, 2017

Are they expected to be in 2.0? thanks

@Ponant Ponant closed this as completed Jul 4, 2017
@davidfowl
Copy link
Member

@Ponant you might be better off calling SHA256.Create()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants