ClosedXML is not compatible with .NETCoreApp 1.1 - visual-studio

I'm trying to add ClosedXML and iText7 to my .NETCore project for school. But every single time I try to install these packages I get the same error:
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
Does anyone know a solution for this problem? I work with Visual Studio 2017 Enterprise Edition. Or does anybody has a suggestion to generate Excels and pdfs with .NET Core?

https://www.nuget.org/packages/ClosedXML
As you can see, ClosedXML depends on .NETFramework 4.0.
http://www.dotnetcurry.com/dotnet/1308/dotnet-core-future-of-dotnet-framework
Right-click on the startup project and click properties. In the application tab, click the Target framework dropdown and .NET Framework >= 4.5. You will lose the cross platform compatibility.
I personally haven't found an ideal export/import solution for excel files but maybe this might work for you: https://www.nuget.org/packages/Shaman.EPPlus/

Related

How do I fix missing NuGet references?

I'm using Visual Studio Professional 2017, version 15.6.6. A co-worker gave me a solution which he says I should be able to open and rebuild without any problems. There seems to be something wrong with either the NuGet packages and/or Framework. Co-worker will only say it must be something wrong with my computer, so I'm hoping someone here can help.
I tried right clicking on the solution and picking "Restore NuGet Packages". The references still have the yellow triangle by them. I tried to rebuild anyway and got the message "The reference assembilies for framework ".NETFramework, Version=v6.0" were not found. I looked at the project properties and saw the target framework was blank. I tried choosing .NET Framework 4.6, but that gave me multiple errors of the type "Package [name of NuGet package] is not compatible with net46(.NETFramework, Version=v4.6)." The co-worker had mentioned trying .NET Core before, so I tried downloading .NET Core 3.1 from this site: https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk. I installed it (including restarting my computer), but don't see .NET Core in the Target framework. Can anyone help guide me getting this solution running?
Here's an image showing the missing references (yellow triangle) on the right and the reference error message when I tried to rebuild.
Here's an image after I set the framework to 4.6 and showing the target framework choices I have available:
We can see that:
.NET 6 is supported by Visual Studio 2022 and Visual Studio 2022 for Mac (and later versions).
You can update to VS2022 and try again.

Cannot Select .Net Core Version for New Projects

Until recently, when creating a .Net Core project, I've been able to select what version of Core to use for it. Since a recent update of Visual Studio 2019, any library project I've created for .Net Core has defaulted to version 3.0. There do not appear to be any options during project creation to select a different version.
For the time being, I need to create projects using .Net Core 2.2, so I'm wondering if anyone knows how to get that option back. For now, I've just been manually changing the target version after creation, but that seems hacky, and I suppose it may be leaving me with bundled references I don't need, or omitting ones that I do.
Update
After installing tons of SDKs, I still do not see the option to choose a framework upon project creation. The documentation for Visual Studio 2019 shows the option as it appears for .NET Framework projects:
... but when creating .NET Core or Standard projects, I am not presented with the option to choose the version:
Is the policy, now, that all projects default to the latest, and if you want something else, you have to change it in the project properties?

How to get NuGet options in Visual Studio 2017 Community?

I am struggling with creating NuGet packages. I am using Visual Studio 2017 Community edition.
I have seen a couple of videos that show a "Pack" option on the menu when right-clicking the project in Solution Explorer. However, I do not have that option. Is this one of the features in the other (non-Community) versions of Visual Studio? I believe I have also seen a "create NuGet package on build" option mentioned somewhere. I cannot find that either.
I have tried various ways of using nuget, dotnet, and msbuild from the command line(s), but haven't had much success. Very frustrating.
Any help is appreciated.
If you really want to use Visual Studio, I would recommend installing an extension that helps you with that problem. For example, this one. The options people have in videos depend on the extensions they have installed. For you, it is the same.
Alternatively, just use the command-line tooling for this as explained here or for .NET Core here or here.
dotnet/msbuild pack is only available for SDK-style projects, but I believe works for all versions of Visual Studio, as well as on the command line. .NET Core introduced these SDK-style projects, which can be identified by <Project Sdk="Microsoft.NET.Sdk">. If your project (.csproj if it's a C# project) doesn't have the Sdk property or import Microsoft.NET.Sdk in either of the two other ways, then it's not an SDK style project and doesn't support packing in this way. Another obvious difference between the two styles of projects is that SDK projects are only a few lines long from the new project template and don't list files in the project, whereas old style projects are typically a full screen long, even from a new project template with only a single class file, and it does list individual files in the project. If you want to continue with this project type, you'll need to use nuget.exe pack and you'll probably want to create a .nuspec file to define some of the package metadata.
However, using SDK style projects is the future, it just takes time for all of Microsoft's existing project types to migrate. It's much simpler to use, so personally I would avoid old style projects unless you're using a project type (like ASP.NET, not ASP.NET Core) that doesn't support it.
All of this is confusing for anyone new to the .NET ecosystem. My recommendation is 1. when you install Visual Studio, when making your workload selections, make sure in the component list that .NET Core is selected, whatever the newest version of .NET Core that is available at the time of installation. When creating a new project in Visual Studio, always select the .NET Core version, or .NET Standard version of any new project template, even if you want to target the (Windows) .NET Framework, in which case you edit the .csproj and change <TargetFramework>netstandard2.0</TargetFramework> to <TargetFramework>net45</TargetFramework>, although I would recommend multi-targeting possible by adding a s to the element name and using a semi-colon separated list: <TargetFrameworks>net45;netstandard2.0</TargetFrameworks>. So, avoid the "Class Library (.NET Framework)" template, instead use "Class Library (.NET Standard)" and then change the target if you have to.
#zivkan led me down the right path. Changing my project types to .Net Core from .Net Framework made all the options I mentioned in my original post available. No extensions were needed.
My .Net Core class library project now has the Pack and Publish options available on the project's context menu. In addition, there is a another tab (Package) on the project properties page. On that page there is a "Generate NuGet package on build" option along with version, name, tags and other properties.
I have done much .Net framework development, but have been ignoring .Net Core and the newer options. I guess I need to dig in and learn about them.

AjaxControlToolkit download

I have a Visual Studio 2010 project which I am converting to Visual Studio 2015.
I have two questions:
The project is currently using AjaxControlToolKit 4.1.60501.0. Should I upgrade it to latest version AjaxControlToolkit 17.1.1? Would there be any coding changes?
I created a sample project and installed AjaxControlToolkit 17.1.1 from Nuget package. I see it in references and also all the Ajax controls in toolbox. However, I do not see ToolKitScriptManager. I also tried to install using exe from DevExpress etc. but still don't find ToolKitScriptManager.
Please guide how to get it.
It really depends on your needs and your project structure.
We have upgrade guide for old versions: https://github.com/DevExpress/AjaxControlToolkit/wiki/Upgrading-from-v7.x-and-below
You can get to know from there, that ToolkitScriptManager is removed, so you need to replace it with standard ASP.NET ScriptManager.
If you use AjaxFileUpload in your project, it's strongly advised to upgrade it to the latest version, because v17.1.1 contains major security fixes.
As a general rule, we advise you to use the latest version of the toolkit, because we can not deliver bug fixes and improvements to the old versions.

Is TPL DataFlow included with either .NET 4.5 or .NET 4.5.1?

I'm confused. We upgraded our project recently to .NET 4.5.1. We installed .NET 4.5.1 on our servers.
I'm referencing assembly System.Threading.Tasks.Dataflow from the GAC at C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Threading.Tasks.Dataflow\v4.0_4.5.9.0__b03f5f7f11d50a3a\System.Threading.Tasks.Dataflow.dll
CopyLocal is set to false as (I assume) it's part of the Framework, so should be already installed wherever the app is deployed.
The trouble is, when running on the server, it says it can't find this assembly.
I've read here that is is part of .NET Framework 4.5:
but the library is now built-in with .NET 4.5.
...and I've read here that it isn't!
The TPL Dataflow Library (System.Threading.Tasks.Dataflow namespace) is not distributed with the .NET Framework 4.5
What gives? It doesn't look like it is. Is it just part of the 'targetting pack'? Is it me, or are these in-place upgrades more agro than they're worth?!
I'm not sure why that page says it is part of .NET 4.5 -- it's still an out-of-band NuGet release, like Entity Framework, MVC, etc.
I recognize this question is pretty old, but I wanted to add my solution as well. I found adding the below two items to the Visual Studio 2019 install (run Visual Studio Installer > Modify > .Net Desktop Development) the problem went away and it was able to pull System.Threading.Tasks.Dataflow from the GAC.
Edit: Installing Visual Studio 2015 also seemed to be required. Obviously it isn't VS 2015 itself, just something it comes with. But there are too many packages for me to figure out which one easily.
Edit2: This isn't really the best solution, more of a stopgap. MS suggests downloading it through Nuget. https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.dataflow?view=netcore-3.1
The TPL Dataflow Library (the System.Threading.Tasks.Dataflow namespace) is not distributed with .NET. To install the System.Threading.Tasks.Dataflow namespace in Visual Studio, open your project, choose Manage NuGet Packages from the Project menu...

Resources