damianh / LibLog

LibLog is a single file for you to either copy/paste or install via nuget, into your library/framework/application to provide a logging abstraction.
MIT License
929 stars 153 forks source link

LibLog 5.0.6 in netstandard2.0 library cannot be used in .Net Framework app #273

Closed SeanSnyders closed 4 years ago

SeanSnyders commented 4 years ago

I have a library, call it libX that is netstandard2.0 compliant and uses LigLob 5.0.6. This library libX needs to be used in a project that targets .net framework 4.6.2 or 4.7.1. I get errors on installing my library libX due to LibLog 5.0.6 not supporting these frameworks and is a dependency of my library libX. Below is an example of the error I get from NuGet for 4.7.1 project:

Could not install package 'LibLog 5.0.6'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
System.InvalidOperationException: Could not install package 'LibLog 5.0.6'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
  at NuGet.ProjectManagement.MSBuildNuGetProject.InstallPackageAsync (NuGet.Packaging.Core.PackageIdentity packageIdentity, NuGet.Protocol.Core.Types.DownloadResourceResult downloadResourceResult, NuGet.ProjectManagement.INuGetProjectContext nuGetProjectContext, System.Threading.CancellationToken token) [0x00779] in <7a2d2afbbb674cd48052281699c39e01>:0 
  at NuGet.PackageManagement.NuGetPackageManager.ExecuteInstallAsync (NuGet.ProjectManagement.NuGetProject nuGetProject, NuGet.Packaging.Core.PackageIdentity packageIdentity, NuGet.Protocol.Core.Types.DownloadResourceResult resourceResult, System.Collections.Generic.HashSet`1[T] packageWithDirectoriesToBeDeleted, NuGet.ProjectManagement.INuGetProjectContext nuGetProjectContext, System.Threading.CancellationToken token) [0x00110] in <7a2d2afbbb674cd48052281699c39e01>:0 
  at NuGet.PackageManagement.NuGetPackageManager.ExecuteNuGetProjectActionsAsync (NuGet.ProjectManagement.NuGetProject nuGetProject, System.Collections.Generic.IEnumerable`1[T] nuGetProjectActions, NuGet.ProjectManagement.INuGetProjectContext nuGetProjectContext, NuGet.Protocol.Core.Types.PackageDownloadContext downloadContext, System.Threading.CancellationToken token) [0x00924] in <7a2d2afbbb674cd48052281699c39e01>:0 
  at NuGet.PackageManagement.NuGetPackageManager.ExecuteNuGetProjectActionsAsync (NuGet.ProjectManagement.NuGetProject nuGetProject, System.Collections.Generic.IEnumerable`1[T] nuGetProjectActions, NuGet.ProjectManagement.INuGetProjectContext nuGetProjectContext, NuGet.Protocol.Core.Types.PackageDownloadContext downloadContext, System.Threading.CancellationToken token) [0x00aa3] in <7a2d2afbbb674cd48052281699c39e01>:0 
  at NuGet.PackageManagement.NuGetPackageManager.ExecuteNuGetProjectActionsAsync (NuGet.ProjectManagement.NuGetProject nuGetProject, System.Collections.Generic.IEnumerable`1[T] nuGetProjectActions, NuGet.ProjectManagement.INuGetProjectContext nuGetProjectContext, NuGet.Protocol.Core.Types.PackageDownloadContext downloadContext, System.Threading.CancellationToken token) [0x011ab] in <7a2d2afbbb674cd48052281699c39e01>:0 
  at NuGet.PackageManagement.NuGetPackageManager.InstallPackageAsync (NuGet.ProjectManagement.NuGetProject nuGetProject, NuGet.Packaging.Core.PackageIdentity packageIdentity, NuGet.PackageManagement.ResolutionContext resolutionContext, NuGet.ProjectManagement.INuGetProjectContext nuGetProjectContext, NuGet.Protocol.Core.Types.PackageDownloadContext downloadContext, System.Collections.Generic.IEnumerable`1[T] primarySources, System.Collections.Generic.IEnumerable`1[T] secondarySources, System.Threading.CancellationToken token) [0x00121] in <7a2d2afbbb674cd48052281699c39e01>:0 
  at NuGet.PackageManagement.NuGetPackageManager.InstallPackageAsync (NuGet.ProjectManagement.NuGetProject nuGetProject, NuGet.Packaging.Core.PackageIdentity packageIdentity, NuGet.PackageManagement.ResolutionContext resolutionContext, NuGet.ProjectManagement.INuGetProjectContext nuGetProjectContext, System.Collections.Generic.IEnumerable`1[T] primarySources, System.Collections.Generic.IEnumerable`1[T] secondarySources, System.Threading.CancellationToken token) [0x000d3] in <7a2d2afbbb674cd48052281699c39e01>:0 
  at JetBrains.ProjectModel.NuGet.Operations.NuGetInstallOperation+<>c__DisplayClass5_0.<InstallAsync>b__0 (NuGet.ProjectManagement.NuGetProject nuGetProject, System.Threading.CancellationToken token) [0x000a5] in <f5ccdf450d834398a3aabbdd4c4e295a>:0 
  at JetBrains.ProjectModel.NuGet.Operations.NuGetInstallOperation.InstallInternal (JetBrains.ProjectModel.IProject project, System.String packageId, System.String packgeUserStr, JetBrains.ProjectModel.NuGet.Configs.NuGetFeedContext feedContext, System.Int32 nestedLevel, JetBrains.ProjectModel.NuGet.Logging.NuGetNotificationMode mode, JetBrains.ProjectModel.NuGet.Operations.NuGetOperationReporter reporter, System.Func`3[T1,T2,TResult] nativeInstall) [0x003e6] in <f5ccdf450d834398a3aabbdd4c4e295a>:0 

Could not install package 'LibLog 5.0.6'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
snakefoot commented 4 years ago

Strange since both both "net45" + "netstandard2.0" should work just fine for "net471".

Have you tried upgrading to latest version of VS2017 / VS2019 ?

If you have a solution that will fix your nuget-issue, then please tell.

SeanSnyders commented 4 years ago

Updated to latest Visual Studio 2019: image

But still getting this:

Could not install package 'LibLog 5.0.6'.
You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2',
but the package does not contain any assembly references or content files that are compatible with that framework.
For more information, contact the package author.
snakefoot commented 4 years ago

Don't know much about Visual Studio for Mac. Maybe ask Microsoft/Xamarin for help why this nuget-package doesn't work in their program. Maybe they can give a hint.

damianh commented 4 years ago

Hmm VS for Mac is not VS2019 but that shouldn't matter.

I get errors on installing my library libX due to LibLog 5.0.6 not supporting these frameworks and is a dependency of my library libX.

Assuming your libx is a nuget package it should NOT bring a dependency on LibLog. LibLog is installed as a developmentDependency https://github.com/damianh/LibLog/blob/master/src/LibLog/LibLog.nuspec#L12 and should look like this in your libx's csproj: https://github.com/NuGet/Home/wiki/DevelopmentDependency-support-for-PackageReference#example and https://github.com/blehnen/DotNetWorkQueue/blob/94845a3b34c4bc4518478075efc16286b01eb5e3/Source/DotNetWorkQueue/DotNetWorkQueue.csproj#L57-L60 If it doesn't look like this, you probably manually added the package reference instead of doing dotnet package add.

damianh commented 4 years ago

Am pretty certain I identified the issus and I know plenty of people are using LibLog with issues with upstream libs and dependencies. Closing - unless it turns out to be something else.