tonerdo / dotnet-env

A .NET library to load environment variables from .env files
MIT License
427 stars 50 forks source link

Target also classic .NET framework for better compatibility #11

Closed stil closed 6 years ago

stil commented 6 years ago

I had a lot of troubles installing this library in my classic .NET project. For now I just copied files to my project, but I'd rather install dotnet-env as NuGet package.

If you accept this PR, can you please publish new version on NuGet?

rogusdev commented 6 years ago

Thank you for this contribution, and highlighting this concern so directly!

I have done some research on this, and I think we should just change from netstandard2.0 down to netstandard1.1 -- rather than adding net46.

Could you try that change and see if it works for your project?

If so, I will gladly merge just downgrading fromnetstandard2.0 to netstandard1.1 because I very much doubt this project requires any newer APIs -- although I have not confirmed that yet and am hoping you can do that with a quick test on your end.

Sources: https://github.com/dotnet/standard/blob/master/docs/versions.md https://msdn.microsoft.com/en-us/library/cc668079.aspx https://docs.microsoft.com/en-us/dotnet/standard/frameworks https://docs.microsoft.com/en-us/dotnet/standard/net-standard

Thanks!

stil commented 6 years ago

I was getting following error:

System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51

This is when I install DotNetEnv to classic .NET 4.7.1 ASP.NET MVC project.

When I tried to create fresh ASP.NET MVC project at home, this time it worked. I'm going to do additional debugging and I'll reply back.

I'm aware that .NET Standard and .NET Framework should be compatible with each other. Yes, you can lower .NET Standard version and it'll benefit many people who are forced to use lower .NET version, but my case wasn't about downgrading but rather that .NET Standard and .NET Framework didn't smoothly worked out together.

I'll investigate my problem again when possible and hopefully I'll be able to find exact source of the problem.

Jon-Indico commented 6 years ago

I came across this when researching environment variables in .NET: https://docs.microsoft.com/en-us/dotnet/api/system.environment.setenvironmentvariable?view=netframework-4.7.1#Applies_to

It looks like you need at least netstandard 1.3 for environment variables to be included

rogusdev commented 6 years ago

@jonindico Hmm, if that were true, then it would not have worked when he added net46, would it?

rogusdev commented 6 years ago

Oh, my bad, I must have brain farted hard when I suggested netstandard1.1 since that isn't even net46! It does indeed need to be netstandard1.3 exactly as you say @jonindico and it says exactly that in all the docs I linked to above, no idea how I messed that up. So perhaps we just shift down to netstandard1.3 I can try that and see what happens.

rogusdev commented 6 years ago

@tonerdo hey man, I notice that you actually explicitly changed this back in the day: https://github.com/tonerdo/dotnet-env/commit/6291bf496580c46187102f6cae80934582341e9c -- do you have any other light to shed on this one?

rogusdev commented 6 years ago

I created a new PR for netstandard1.3 -- thanks again @jonindico and @stil for raising the issue! https://github.com/tonerdo/dotnet-env/pull/14