Are xdt transforms not supported in nuget packages installed in a netstandard 2.0 project? - nuget

I have a nuget package that has .xdt transforms for a app.config file. The xdt files are included in the netstandard 2.0 project that builds the nuget package. Their build action is set to content/do not copy. When I install the package in a .net framework project, the xdt transforms work corectly, but when I install the package in a netstandard 2.0 project, the xdt files do not transform the config file, but instead are added to the project with a build action of C# Compiler. Does nuget not support xdt transforms on netstandard projects?

You are right, xdt transforms aren't supported in PackageReference environment. This includes both sdk-based projects as well as classic .net framework projects using PackageReference instead of packages.config. You can follow this GitHub issue for more details. There is also a sample package that shows how to use build-time logic to apply transforms instead to work in all environments.
Also note that .NET Standard and .NET Core projects don't have an app.config file that a transform could apply to. This is only relevant for .NET Framework / classic Web Applications. (with maybe an exception for IIS settings for ASP.NET Core apps but they don't affect the app itself, only IIS hosting environment).

Related

What is the best approach to read from both Web.config and appsettings.json in a .NET Standard library?

We have an old .NET Framework nuget package built with .NET Framework that reads settings from Web.configs files on .NET Framework projects using the ConfigurationManager.AppSettings class. Now, we need to migrate it to .NET Standard to be able to use it on .NET Core projects also.
Is there an elegant way to try to find and read settings from both Web.config files when running in .NET Framework, and from appsetting.json when running on a .NET Core project? Does it make sense?
Also, it makes sense to have 2 different nuget packages, one for use only on .NET Framework projects and another to use only in .NET Core projects?
The main goal is to read setting independent of the .NET version it is running on.

NuGet package not installing in .NET Framework

I have created .net standard library project and I have created nuget package for this library, Now I need to install this package in both application .Net Core and .Net Framework4.5. Working fine in .Net Core but while installing .Net framework project it was showing below exception.
You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.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.
Please let me know the right approach to resolve this.
The library that you have created targets .NET Standard 2.0, as stated in your tags. .NET Framework 4.5.2 does only implement .NET Standard up to version 1.2, that is why the assemblies are not compatible.
You should change your library to a .NET Standard version that is implemented by both .NET Core and .NET Framework or upgrade your .NET Framework version accordingly.
You can find the version mappings here, credits to #Matt Ward for providing the source.

Build .NET Core 3.1.1 from git repository

I would like to build from source the .NET Core 3.1 CLR and libraries. I checked out the latest from https://github.com/dotnet/runtime. Running the build scripts will produce the next version of .net and not 3.1.1. Can you tell me how to get the .NET Core 3.1.1 source and build it? I want to be able to produce a debug version of the core so that I can add tracing and logging.
Go to 3.1.1 tag in dotnet/coreclr repo (https://github.com/dotnet/coreclr/tree/v3.1.1)
The entire coreclr repo has merged (along with corefx, corert and the installer) to dotnet/runtime.
The dotnet/coreclr repo is an archive currently, which still holds all the old tags.

Support .net Core for a nuget package

I have created a nuget package implementing TinyEncryptionAlgorithm but it supports only .Net 4.6.1
Now I want to use this nuget into a .net core application NETStandard.Library and I don't know what I have to do.
Do I have to implement a completely new nuget package or I can include both assemplies in the same nuget package?
I have tried to create a NetStandard library and reference it from a .Net 4.6.1 but this is not working.
To support multiple version of .Net you must create portable libs.
Here is a tutorial of how to publish nuget for portable libs.
https://docs.nuget.org/ndocs/guides/create-net-standard-packages-vs2015

Install Entity Framewok v5 in Webmatrix 2 RC

I'm working on a project with Entity Framework in Webmatrix 2 RC, so I need to use Entity Framework v.5 RC because of conflicts between previous versions and .NET Framework 4.5.
The two ways I know to install NuGet packages in Webmatrix are from the NuGet Gallery on the Webmatrix ribbon and from the package manager in ASP.NET Web Pages Administration: either solution proposes only Entity Framework v4.3.1.
I have downloaded Entity Framework v.5 RC with the Package Manager Console of Visual Web Developer and copied the EntityFramework.dll into the bin folder of my project.
This solution works but I wonder if exists a way to install a not recommended NuGet package that doesn't require the use of Visual Web Developer.
You can use nuget.exe or NuGet Package Explorer, both are standalone and lightweight. You'll still have to manually add references to the files though.