Build error: The "ResolveTargetingPackAssets" task failed unexpectedly - c#

I am trying to build a dotnet core project on a linux machine.
Build fails with the following error:
: error MSB4018: The "ResolveTargetingPackAssets" task failed
unexpectedly.
[/var/lib/jenkins/workspace/MyProject/MyProject/MyProject.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5)
I don't know what to do, can someone please advise.
See csproj below.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="Flurl.Http" Version="2.4.2" />
<PackageReference Include="Flurl.Http.Xml" Version="1.6.1" />
<PackageReference Include="LazyCache" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="5.0.0-rc4" />
<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.5.0" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.13" />
</ItemGroup>
<ItemGroup>
<Folder Include="Security\" />
</ItemGroup>
</Project>

Related

Having Trouble Updating NuGet packages in my .NET Core app

Every time I attempt to update 'Microsoft.Extensions.Primitives' it fails as follows:
GET https://api.nuget.org/v3/registration4-gz-semver2/microsoft.extensions.primitives/index.json
OK https://api.nuget.org/v3/registration4-gz-semver2/microsoft.extensions.primitives/index.json 142ms
Getting restore information for project /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj
Running non-parallel restore.
Reading project file /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj.
Persisting no-op dg to /Users/developer/Source/WebApp-001/WebApp-001/obj/WebApp-001.csproj.nuget.dgspec.json
Restoring packages for /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj...
Restoring packages for .NETCoreApp,Version=v3.1...
GET https://api.nuget.org/v3-flatcontainer/microsoft.extensions.primitives/index.json
OK https://api.nuget.org/v3-flatcontainer/microsoft.extensions.primitives/index.json 3473ms
Resolving conflicts for .NETCoreApp,Version=v3.1...
Unable to find package Microsoft.Extensions.Primitives with version (>= 3.1.1)
- Found 36 version(s) in nuget.org [ Nearest version: 3.1.0 ]
Package restore failed. Rolling back package changes for 'WebApp-001'.
I'm using .NET Core 3.1 as my target framework on macOS using Visual Studio. I've tried updated from the terminal as well, no luck. This NuGet package and a few others are not able to be updated to version 3.1.1. They all appear to be "stuck" on version 3.1.0.
Maybe somebody has encountered this issue before? I don't understand why it is "[u]nable to find package Microsoft.Extensions.Primitives with version (>= 3.1.1)."
Copy of my .csproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>WebApp_001</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'TheMidtownModel' ">
<StartAction>Project</StartAction>
<ApplicationURL>http://localhost:5002</ApplicationURL>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Sendgrid" Version="9.12.6" />
<PackageReference Include="React.AspNet" Version="5.1.2" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore" Version="3.3.0" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64" Version="3.3.0" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64" Version="3.3.0" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x64" Version="3.3.0" />
<PackageReference Include="JavaScriptEngineSwitcher.Extensions.MsDependencyInjection" Version="3.3.0" />
<PackageReference Include="Twilio.AspNet.Core" Version="5.33.1" />
<PackageReference Include="Twilio" Version="5.37.3" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.19" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<Content Remove="wwwroot\css\bootstrap-grid.min.css" />
<Content Remove="wwwroot\css\bootstrap.min.css" />
<Content Remove="wwwroot\css\bootstrap.min.css.map" />
<Content Remove="wwwroot\js copy\__bootstrap.bundle.min.js" />
<Content Remove="wwwroot\js\bootstrap.js" />
<Content Remove="BackUpFiles\appsettings.Development.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Admin\" />
<Folder Include="Views\RoleAdmin\" />
<Folder Include="Views\Claims\" />
<Folder Include="Views\FileUpload\" />
<Folder Include="Authorization\" />
<Folder Include="Views\Shared\Layouts\" />
<Folder Include="Views\Shared\Partial\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Migrations\20191216040205_SecondUpdateAlbumField.cs" />
<Compile Remove="Migrations\20191216040205_SecondUpdateAlbumField.Designer.cs" />
<Compile Remove="Migrations\20191216040329_ThirdUpdateAlbumField.cs" />
<Compile Remove="Migrations\20191216040329_ThirdUpdateAlbumField.Designer.cs" />
</ItemGroup>
</Project>

Azure function 2.x ILogger is not competible with .net core ILogger?

I have been trying to refer a .net core library project into my Azure function project to call one of the process defined in a .net core class library.
The .net core library project uses ILogger.
However, whenever I try to run a function I get the following error:
[29/11/2019 1:08:35 AM] The 'Function1' function is in error:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'.
Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type
ILogger`1. Make sure the parameter Type is supported by the binding.
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(),
This is my code:
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
// string templateFile = Path.Combine(context.FunctionAppDirectory, "Data", "HelloHttpOutputTemplate.txt");
Startup.Main(null).Wait();
}
I also confirmed that my .net core project as well as function project are referring a same version of ILogger:
'microsoft.extensions.logging.abstractions\3.0.0\lib\netstandard2.0'
If I remove a .net core library project reference from within function project then it works.
My function CS Project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<Content Include="..\Accounts.Console\appsettings.json" Link="appsettings.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.28" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Accounts.Console\Accounts.Console.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>
My .net core Library project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<StartupObject></StartupObject>
<ApplicationIcon />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="librdkafka.redist" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.0.0" />
</ItemGroup>
</Project>
Update:
Have use .net core 3.0 now.
But still meet the same error:
This is my .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="librdkafka.redist" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.28" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Solution:
Downgrading the version of Microsoft.Extensions.Http, Microsoft.Extensions.Logging.Console, Microsoft.Extensions.Logging.Debug and Microsoft.Extensions.Options from 3.0.0 to 2.2.0. Then error will be solved.
Original Answer:
I have reproduce your error:
Cause:
Assembly conflict. The key is your last four assembly references.
Solution:
Change them to 2.2.0. Things works fine on my side. Please have a try on your side and let me know if you have difficulties.
My .csproj file:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="librdkafka.redist" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

Dapper is throwing System.Data.SqlClient.SqlConnection exception after upgrading System.Data.SqlClient to version 4.5.0-preview2

I recently upgraded one of my ASP.NET Core applications from a net461 app to ASP.NET Core 2.0 app since the only thing that was holding me back in the past was System.Transactions (which is now supported).
After upgrading I get an error when accessing any function that is using the following:
protected static TransactionScope GetTransactionScope()
{
TransactionOptions transactionOptions = new TransactionOptions
{
IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted,
Timeout = TransactionManager.MaximumTimeout
};
return new TransactionScope(TransactionScopeOption.Required, transactionOptions);
}
Error:
Enlisting in Ambient transactions is not supported.
Based on my google research I saw a few open issues on GitHub related to this and they all say that upgrading System.Data.SqlClient to the latest pre-release will fix the issue.
I believe this fixed that issue, but caused another one. I am using Dapper v1.50.2 in my project and I think it is unable to use the pre-release version of System.Data.SqlClient because I am now getting the following error:
The type initializer for 'System.Data.SqlClient.SqlConnection' threw
an exception
Does anyone know how I can use Dapper and also get rid of this Ambient transactions error? I am not sure how System.Transactions was ported over when an error like this is occurring.
I've recently fixed this issue.
First, in your Web.csproj replace
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
with
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ApplicationInsights.HostingStartup" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OAuth" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authorization.Policy" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.AzureAppServicesIntegration" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.Internal" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Extensions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Localization.Routing" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.MiddlewareAnalysis" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ApiExplorer" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Localization" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.NodeServices" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.HttpSys" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Razor" Version="2.0.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.TraceSource" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.WebEncoders" Version="2.0.0" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.1" />
in this package references I removed all references on EntityFramework and SqlServer caching.
then, add reference to older System.Data.SqlClient
<PackageReference Include="System.Data.SqlClient" Version="4.3.0" />
Hope it helps!
I want to share my solution with the issue message:
The type initializer for 'Microsoft.Data.SqlClient.SqlConnection'
threw an exception.
Also the 'Microsoft.Data.SqlClient.SqlConnectionFactory' appeared in the issue.
This appears using Dapper or Microsoft.Data.SqlClient libraries.
Let me show you, I have two C# projects:
ConnectionToDB (Project used in 2.)
ASP.NET Core App
The problem that I found was that 1. had all the neccessary libraries/dependencies to work but for any kind of reason was not working. The problem was that the Microsoft.Data.SqlClient has to be inside 2. too to work. I don't know why but this may help to anyone.
Regards!
Use NuGet package manager and search for "System.Data.SqlClient", install the latest and the exception goes away.

Asp.Net Core with Docker - Duplicate 'Content' items were included

I have a problem when I would like to deploy my app with docker.
I'm using ASP.Net Core with docker.
This an error message:
/usr/local/share/dotnet/sdk/1.0.4/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.DefaultItems.targets(188,5):
error : Duplicate 'Content' items were included. The .NET SDK includes
'Content' items from your project directory by default. You can either
remove these items from your project file, or set the
'EnableDefaultContentItems' property to 'false' if you want to
explicitly include them in your project file. For more information,
see https://aka.ms/sdkimplicititems. The duplicate items were:
'wwwroot/_version.txt'
[/Users/xxxxxx/Projects/api-test/TestApi/TestApi.csproj]
Here's my csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1.1</TargetFramework>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<UserSecretsId>0a7aa24d-009c-4d0b-b0fd-e8be397b0784</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.0.2" />
<PackageReference Include="CoreCompat.System.Drawing" Version="1.0.0-beta006" />
<PackageReference Include="Google.Cloud.Storage.V1" Version="1.1.0-beta01" />
<PackageReference Include="HtmlAgilityPack.NetCore" Version="1.5.0.1" />
<PackageReference Include="MailKit" Version="1.16.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.1.0-beta2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.7-m61" />
<PackageReference Include="RazorLight" Version="1.1.0" />
<PackageReference Include="RazorLight.MVC" Version="1.0.4" />
<PackageReference Include="Serilog" Version="2.5.0-dev-00817" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.1-dev-10155" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="2.2.0-dev-00721" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="1.0.0" />
<PackageReference Include="WkWrap.Core" Version="1.0.2" />
<PackageReference Include="ZXing.Net" Version="0.15.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="SQL\" />
<Content Include="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
I think the problem is with a _version.txt file which is currently on the server (I can;t say that because I do not have an access) and It tries to duplicate it.
Would you mind to help me with that i
The .NET SDK includes Content items from your project directory by default, so wwwroot\_version.txt is already present in your project. Your project file is then attempting to add it again, which causes the error.
You can use Update instead of Include to cause the existing content item to be updated, rather than including it twice.
So, you just have to change
<Content Include="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
to
<Content Update="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>

Resharper shows an error from IO Stream in MVC Core, but I don't understand

I am trying to read the body of a HTTP Request into a StreamReader in an MVC project.
I get this strange error and it's more than I know about .NET to solve it.
here's the detail from my CSPROJ:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" />
<PackageReference Include="NReco.Data" Version="1.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
I actually ran in to this bug yesterday after adding the comment to the question. The error is caused by a bug in resharper, you should still be able to build and run the solution still.
Make sure you are running the latest version of resharper and have cleared your cache for resharper too. If the problem still persists submit a bug report to JetBrains.

Categories

Resources