Whenever I create a new web project using my visual studio 2017, it creates it with a file named packages.config which contains reference for:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net461" />
At my work we are not allowed to use any nuget packages.
So everytime I have to manually go and uninstall Microsoft.CodeDom.Providers.DotNetCompilerPlatform, which will remove the packages.config file and updates my web.config file.
Is there a way I can prevent visual studio 2017 from doing this when I create a project itself?
Thank you!
I am building a .NET NanoFramework demo using the ESP32_VROOM_32 board. I'm having trouble figuring our the correct combination of NuGet packages to avoid getting an assembly mismatch error when I try to debug my solution on the actual hardware. This error I keep getting when I push to the device is:
[Found assemblies mismatches when checking for deployment pre-check.]
The combination of packages I currently have installed are:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AMQPNetLite.nanoFramework" version="2.3.0.39" targetFramework="netnanoframework10" />
<package id="nanoFramework.CoreLibrary" version="1.7.3-preview.4" targetFramework="netnanoframework10" />
<package id="nanoFramework.Hardware.Esp32" version="1.2.1-preview.12" targetFramework="netnanoframework10" />
<package id="nanoFramework.ResourceManager" version="1.0.0-preview.15" targetFramework="netnanoframework10" />
<package id="nanoFramework.Runtime.Events" version="1.4.2-preview.8" targetFramework="netnanoframework10" />
<package id="nanoFramework.Runtime.Native" version="1.4.0-preview.1" targetFramework="netnanoframework10" />
<package id="nanoFramework.System.Collections" version="1.0.1-preview.7" targetFramework="netnanoframework10" />
<package id="nanoFramework.System.Math" version="1.2.0-preview.16" targetFramework="netnanoframework10" />
<package id="nanoFramework.System.Net" version="1.4.1-preview.21" targetFramework="netnanoframework10" />
<package id="nanoFramework.System.Text" version="1.0.0-preview.22" targetFramework="netnanoframework10" />
</packages>
My question is, is there a reliable systematic way to determine which combination of NuGet packages will work together with the firmware installed on the device?
I have tried many different combinations and can't get anything to work.
Currently, I have 1.4.0-preview.208 firmware installed on the ESP32, which appears to be the latest stable version.
There is no direct relation between the versioning of the C# libraries and the native firmware implementation. That's because each part has it's own separate development cycle.
The declaration is on which native version it requires. From managed to native, not the other way around.
This is showned on the NuGet description. If you want to learn more about this, take a look at this blog post here.
In the meantime know that stable releases have been published for all class libraries and firmware. The links for the firmware images have been updated.
Each NuGet package has a declaration on which other packages it depends on and which version. There is no other way to determine a valid package combination.
The fw version you have loaded it's not a stable version, therefore the "preview" in the version. But neither are the NuGets. Which is all OK: if you are using the "preview" firmware you have to use the "preview" NuGets.
Can you post here the error message about the version mismatch that you get? This will help determine what is wrong there.
I'm using VS2019 Pro v16.3.5
I have a solution containing an Azure functions project which references several class library projects.
The top-level project fails to compile with the following error:
System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.Extensions.Logging.Abstractions, Version=2.2.0.0,
Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot
find the file specified.
The project does have a package reference: PackageReference Include="Microsoft.AspNetCore.App" and this framework includes the missing dll, so I don't know why it's having trouble.
My thoughts are perhaps one of the referenced projects is depending on a different version but I don't see it.
I did try explicitly referencing the package in the top-level project but this made no difference:
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0.0" />
Here is a current copy of the top-level csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Base.Core.SharedKernel" Version="1.0.0.23885" />
<PackageReference Include="FluentValidation" Version="8.4.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.4.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.5" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.27" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Interfaces.Avaloq.Application\Interfaces.Avaloq.Application.csproj" />
<ProjectReference Include="..\Interfaces.Avaloq.Common\Interfaces.Avaloq.Common.csproj" />
<ProjectReference Include="..\Interfaces.Avaloq.Infrastructure\Interfaces.Avaloq.Infrastructure.csproj" />
<ProjectReference Include="..\Interfaces.Avaloq.Persistence\Interfaces.Avaloq.Persistence.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Problems Referencing the Nuget Package
I can see that assemblies for the "working" package references (such as FluentValidation.dll) can be found in the global packages folder at "C:\Users\bowman_rob_a.nuget\packages". However, the global packages folder does not contain v2.2.0.0 of Microsoft.Extensions.Logging.Abstractions, it contains lots of versions but skips from 2.1.0 to 3.0.0.
If I run from the package manager console: "install-package Microsoft.Extensions.Logging.Abstractions -Version 2.2.0" then I get the following error:
The WriteObject and WriteError methods cannot be called from outside
the overrides of the BeginProcessing, ProcessRecord, and
EndProcessing methods, and they can only be called from within the
same thread
Despite the error, the package does then appear in the project's packages section of solution explorer. However, it is listed with a strange path "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.logging.abstractions\2.2.0"
Problems Referencing the Shared Package
Because v2.2.0.0 is included in the shared package reference "Microsoft.AspNetCore.App" then I guess the assembly should be pulled from there? The assemblies for shared packages reside in "C:\Program Files\dotnet\shared." There are lots of versions of the shared package
"Microsoft.AspNetCore.App" but again 2.2.0.0 is skipped, from 2.1.13 to 2.2.4. However, the folder "C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\2.2.4\Microsoft.Extensions.Logging.Abstractions.dll" does contain v2.2.0.0 of the dll.
Version Conflict
I think the root cause of the problem could be that Azure Functions has a dependency on the nuget package chain: Microsoft.Azure.WebJobs.Extensions --> Microsoft.Azure.WebJobs --> Microsoft.Extensions.Logging.Abstractions. The latest version of Microsoft.Azure.WebJobs.Extensions is 3.0.2 and this leads down to v2.1.0 of Microsoft.Extentions.Logging.Abstractions - this is older than the v2.2.0.0 that's included in the Shared Framework Microsoft.AspNetCore.App. Does anyone know how I can change the version of a Shared Framework that's used by the compiler? I can't find a runtimeconfig.json file anywhere!
Work Around
I have been able to make the solution build by removing the Shared Reference from all projects within the solution and adding each required nuget package individually - using the older 2.1.0 versions.
Make sure none of your packages is above the .NET version of the project.
In my case the installed version of Microsoft.Extensions.Http was 5.0 while the project was in .NET Core 3.1. As soon as I downgraded the library to 3.1 everything went smoothly.
Source: https://github.com/Azure/azure-functions-core-tools/issues/2304
Some info and workaround which may help to resolve the puzzle if someone else meets similar issue.
It is listed with a strange path "C:\Program
Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.logging.abstractions\2.2.0"
FallBackFolders are something used to share packages across users and machines to reduce risk space.
They differ from package sources in that the package assets will be referenced directly and will not be copied into the user's packages folder.
That's why you can't find the package in Global Packages like C:\Users\xxx\.nuget\packages.
For Version Conflict
As you mentioned above, the chain of Microsoft.Azure.WebJobs.Extensions is:
Microsoft.Azure.WebJobs.Extensions --> Microsoft.Azure.WebJobs --> Microsoft.Extensions.Logging.Abstractions(2.1.0)
And since you reference the Microsoft.AspNetCore.App package, the chain of it:
Microsoft.AspNetCore.App(2.2.0) --> Microsoft.Extensions.Logging.Abstractions(2.2.0)
I think this could be the cause of the version conflict.You can remove that package to check if it's another workaround.
In addition:
If I create a new Azure Function project in VS16.3.5, we don't need to reference these packages manually:
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
Since Microsoft.NET.Sdk.Functions depends on these packages, nuget will help us downlaod and reference them.
And I tried several kinds of Azure functions project, but none of them need the Microsoft.AspNetCore.App package, so if you don't have specific reason to use that package, you don't need to reference it.
I encountered this issue after upgrading a Nuget package and then reverting. Had to manually delete all bin and obj folders in the solution before it worked again. Cleaning the solution did not help.
I just created a new project using .net 6 and ran into this issue.
I installed entity framework nuget packages:
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools
To support data access into a SQL db.
Both of those libraries defaulted to .net 7 for latest version.
These were the errors I was getting:
[2023-01-16T18:15:16.759Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[2023-01-16T18:15:16.790Z] The 'Function1' function is in error: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Even changing the project to .net 7 didn't resolve it, although I wonder if I would have had to update all the nuget packages to 7. I had to downgrade both of those libraries to .net 6 and it compiled and ran fine.
Regardless, I want to remain on 6 with long term support. The only nuisance now is that nuget wants to upgrade those two libraries to .net 7 so they show as available for an upgrade.
I had the same problem in the WebJob project that was compiled in Azure DevOps and running with Azure WebApp.
I have managed to solve the problem by changing "Use .Net Core" task version to the last version (3.1.x) in Build pipeline.
This was the error message :
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=.......'. The located assembly's manifest definition does not match the assembly reference. (.......)
I had a similar issue on running windows service and had to update config file with newly available version by using redirect technique resolved the issue.
<configuration>
<appSettings />
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I'm on VS2022 trying to run an httptrigger function of funcapp. I downgraded Microsoft.Extensions.Http from 7.0.0 to 6.0.0 and Microsoft.Extensions.Logging.Abstractions to 6.0.3. This worked fine.
I have ASP.Net MVC project. The project contains WebGrease, packages.config:
<package id="WebGrease" version="1.5.2" targetFramework="net462" />
Recently because of (https://www.nuget.org/packages/BundleTransformer.MicrosoftAjax/) I added AjaxMin into my packages.config:
<package id="AjaxMin" version="5.14.5506.26202" targetFramework="net461" />
In my code, I am using IsNullOrWhiteSpace() extension method. The method actually exists in these two libraries:
Visual Studio cannot decided which one has to be used.
I cannot remove the reference to WebGrease, because if I do so, I have the following exception:
How can I solve the conflict?
Thank you
You can use string.IsNullOrWhitespace() directly.
I wrote this code in Webmatrix 2.0 beta:
string Dbfile=HttpContext.Current.Server.MapPath("data/db.db3");
var Db = Simple.Data.Database.OpenFile(Dbfile);
Simple.Data.SimpleDataException: No ADO Provider found.
why??
I'm sure that I have included the reference:
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Simple.Data.Ado" version="0.16.1.0" />
<package id="Simple.Data.Core" version="0.16.1.0" />
<package id="Simple.Data.Sqlite" version="0.16.0.0" />
<package id="System.Data.SQLite" version="1.0.80.0" />
</packages>
In my test application conn is the physical path including the the db filename and calling
cn = Database.OpenConnection(conn);
works for me. When I used OpenFile I also received the No ADO Provider error.
I am using (from NuGet):
Simple.Data.Core 0.16.1.0
Simple.Data.Ado 0.16.1.0
System.Data.SQLite 1.0.80.0
Simple.Data.Sqlite 0.16.0.0
System.Data.SQLite 1.0.80.0
Getting the dlls required for the System.Data.SQlite can be hassle. If you want to do it quickly then download the Nuget extension for VS 2010. Then you can get the dlls from the extensions console.
Make sure you read the extension installations instructions.