I want to use log4net in my .net core 2.1 project but when I add it, it has a yellow exclamation triangle next to it and I get this message in the output window.
warning NU1701: Package 'log4net 2.0.5' was restored using
'.NETFramework,Version=v4.6.1' instead of the project target framework
'.NETCoreApp,Version=v2.1'. This package may not be fully compatible
with your project.
Any idea how I can make the project happy using log4net? what will happen if I try and use it with the exclamation?
Upgrade your Log4net to at least version 2.0.6 (or higher) as from this version it supports .NET Standard 1.3 which allows Log4net to be used on .NET Core.
Note that not everything is supported on .NET Core (eg. AdoNetAppender, SmtpAppender) see the release notes.
Related
In order to properly run CM in a Xamarin Forms project using .Net Standard, what version of .NET Standard should I be targeting? I am currently targeting .NET Standard 2.0 and I'm getting the warning:
"Package 'Caliburn.Micro 4.0.0-alpha.1' was restored using
'.NETPortable,Version=v0.0,Profile=Profile259,
.NETPortable,Version=v0.0,Profile=Profile259,
.NETPortable,Version=v0.0,Profile=net45+win+win81+wp8+wpa81,
.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2,
.NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1,
.NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8'
instead of the project target framework '
.NETStandard,Version=v2.0'. This package may not be fully compatible with your project."
Should I be on .NET Standard 1.6 or 1.0? I've seen the following comment from Nigel:
Caliburn.Micro.Core can target .NET Standard 1.0 so lots of support there.
Caliburn.Micro.Xamarin.Forms will be 1.6.
However, since the forms project will pull in both of those packages in, I am confused as to which version I should target.
My project runs fine in the simulator but crashes on an iOS device. I'm thinking it has something to do with the warning above.
Thanks!
Sean
What I want to do: Upgrade to the latest core and standard versions for my apps and libs that the apps depend on. These apps and libs are currently on 2.2 (latest) and .Net Standard 2.0 for libs.
What have I tried: I have installed the latest versions of all the SDKs, runtimes and the latest IDE of 16.3.2 - I want to attempt to target .NET Core 3.0 and .NET Standard 2.1 for my libraries.
I cannot do any of these things either directly, or by manually messing with project files. It is not in the dropdown for existing projects and if I manually edit the project file, I get an error saying that 3.0 is not a valid SDK version.
If I spawn a new IDE and create a new web app, console app or class lib, I can easily target 3.0, or NetStandard 2.1 - which is fine and proves that it's all installed... but what I don't understand is how to plot a path to migration/upgrade - creating brand new solutions and projects and attempting to recreate the software isn't really an option.
Am I missing something here? The Internet is only really useful for guiding people to how to turn on .NET Core 3 back when it was a preview version, which obviously is no longer the case.
There must be a set of steps to help people migrate from 2.2 core or 2.0 standard ...
If you stumble upon this and wish to know the answer to this scenario, it lies in a file called global.json - a file which may not be part of your solution that is probably hiding in the root folder somewhere.
Change the SDK version in this file to 3.0.100 (run dotnet --list-sdks in a terminal to find the version strings) and you should be good to go.
I built an application with target framework .NET 4.6 using MVC 5 and Entity Framework 6 using Visual Studio 2017 on my Windows 7 machine. I'm now being told that I should have built the application to target .NET 4.0 because the production environment only has 4.0 installed. So I changed the target framework to 4.0 but now the application will not build on my machine.
I'm guessing I also need to downgrade MVC and EF. How is the proper way of doing this?
And which versions of MVC and EF should I install?
Do I need to make any manual changes to web.config?
There is no "proper" way, you have 3 options, in my favorite order:
Update the server and install the latest .net version. (at the time .net 4.6). Make sure used libraries are up to date and not end of life.
Start over in a new project and make sure you target version 4.0: you can copy most of your source files. You'll probably get some compiler errors, but usually they are easily fixed. This way you'll have the benefit that the used template matches the framework and packages version(s).
Re-target the used framework in the project properties and replace the packages which are installed and hope for the best (sometimes you need other packages). Hopefully you used the package manager to install those packages. Maybe the update-packages command helps, but be sure to backup your project first. Some packages become obsolete after time, some are renamed. This is what will cause issues. Also, some of the Methods/API calls will be different, so some rework will be needed.
As for the rest of your questions:
I'm guessing I also need to downgrade MVC and EF. How is the proper way of doing this?
Use the nuget package manager
And which versions of MVC and EF should I install?
The nuget package manager will fix this for you.
Do I need to make any manual changes to web.config?
Sometimes: yes.
I was trying to create a common library for using HttpClient to consume an API. I was planning to make it in .net standard so as to share it with my xamarin.forms project right now and any future ones. However the highest version of .net standard I managed to use was 1.0. HttpClient needs standard2.0. I have included the latest version of .netstandard nuget into my xamarin.forms.
I have noticed that xamarin.forms runs in net4.5. According to the documentations the max I can go with this is standard1.1. Is there any work around around these to a .net standard common project or is my only option to make a .net framework project/xamarin portable library?
I used to be in the same situation and I managed to pull through this. First I tried to upgrade my current PCL project to .netStandard, but it was always failing, so I decided to create a new Project A Class Library (.NETStandard), moved all my files to the new project and re-install all nuget packages.
New project configuration:
Target Framwork: .NET Standard 2.0
Output type: Class Library
Make sure you're using Microsoft Visual Studio > version 15.3
Hope it helps.
I did manage to get HttpClient working in .net standard after manually importing the class. It needed an additional reference which is why it threw an error when I downgraded from .netcore.
This seems to work sometimes and throws reference errors other times. These errors go when I close and re-open visual studios.
I'm using default Roslyn SDK templates that came with Visual Studio 2017. The projects they create target .NET Framework Portable. I'm assuming Roslyn extensibility projects can target .NET Standard \ Core instead of Portable and I'm looking for templates or a sample of Roslyn Analyzer \ Refactoring project that I could study.
Sample of converted analyzer from default analyzer template is available here. There is original analyzer for comparison along with TestAnalyzerStandard which targets .NET standard.
Steps to make it work:
Create new .NET Standard library
Library must target .NET Standard 1.3. This is required if you wish to run analyzer as extension inside VS (extensions target .NET 4.6). Mapping between standard versions and full framework versions is available here. Also if you try to target lower version than 1.3, you will not be able to include required analyzer packages.
Add nuget package for Microsoft.Composition latest version. This is needed by Microsoft.CodeAnalysis.CSharp.Workspaces. If you try to add workspaces first, you will get error that referenced composition package is not compatible.
Add nuget package for Microsoft.CodeAnalysis.CSharp (I'm using latest 1.* version)
Add nuget package for Microsoft.CodeAnalysis.Csharp.Workspaces (version should match the version of Microsoft.CodeAnalysis.CSharp).
At this point you can copy code from portable project and build it. There should be no errors (you may have to close and reopen solution if VS is still displaying red squiggles).
To make VS extension work, just open source.extension.vsixmanifest, go to assets tab and change reference to .NET standard library
To create .nuget package just execute nuget pack Diagnostic.nuspec .. Diagnostic.nuspec is valid for Nuget 2.x. If you are using nuget via package management console in VS 2017 you will have to change <file src="*.dll" ..." to <file src="bin\*\netstandard1.3\*.dll" ....
Those steps are result of my experimentation with analyzers (I previously played with creating DLL which targeted full framework instead of being portable library). They are not by any means official.
I started working on a new Roslyn project and built things one by one instead of using template. https://github.com/IKoshelev/Roslyn.AutoLogging/commit/1f88e3e49141e0fa425c51fdcb3457a7c3d6dcaa
I managed to have the following targeting:
Refactoring project - .NET Standard 1.3 (this .dll will be distributed, version kept to minimum)
UnitTests project - .NET Core 2.0
VSIX project - .NET Framework 4.6 (I believe, only full Visual Studio supports VSIX, so that is okay)
Update Versioning of Roslyn is a bit more complicated right now, i.e. if you want to use your extensions with Visual Studio 2015 you will have to use PCL libraries. More info at the end of this article article on Roslyn