Nuget Packages Conflict .net core - .net-core

I'm working on creating sample for clean architecture. When I had made core and infrastructure projects there were no problems. No I had add new API project and I got problem, picture bellow
I had tried to add project references in csproj but still have a problem, can anyone help me to fix this problem ?
Here is the link for project: https://github.com/danijel88/Clean-Architecture
Regards,
Danijel

Here's a question similar to yours
Here's a sample .csproj. Be sure to have
<TargetFramework>netcoreapp2.2</TargetFramework>
Make sure your project is on 2.2 before updating your packages to 2.2.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Gelf.Extensions.Logging" Version="1.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" />
<PackageReference Include="SlackLogger" Version="2.0.5" />
<PackageReference Include="System.Xml.Linq" Version="3.5.21022.801" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nozomi.Infra.Preprocessing\Nozomi.Infra.Preprocessing.csproj" />
<ProjectReference Include="..\Nozomi.Infra.Service.Identity\Nozomi.Infra.Service.Identity.csproj" />
<ProjectReference Include="..\Nozomi.Infra.Service\Nozomi.Infra.Service.csproj" />
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="Areas\Identity\Pages\_ViewImports.cshtml" />
</ItemGroup>
</Project>

Related

Xamarin.Forms SDK-Style multiplatform project with XAML

Have defined multitarget project:
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;xamarinios10;monoandroid9.0;</TargetFrameworks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.6.0.800" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3" />
<Compile Include="**\Shared\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('xamarinios')) ">
<Compile Include="**\iOS\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('monoandroid')) ">
<Compile Include="**\Android\*.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Shared\MyView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
So, when i make my custom component only in code all compile and works well, but i would like to develop some custom controls using XAML.
But i got error of ambiguous call to method InitializeComponent() in MyView object.
How to make correct conditional configuration in .csproj for compiler to understand *.xaml and *.xaml.cs files ?
Adding these properties to common ItemGroup solved the problem:
<None Remove="**\Shared\*.xaml" />
<Compile Include="**\Shared\*.xaml.cs" DependentUpon="%(Filename)" />
<EmbeddedResource Include="**\Shared\*.xaml" Generator="MSBuild:UpdateDesignTimeXaml" />

VS2019 Error Says Project is Targetting 'netcoreapp3.1' when it is Targetting netcoreapp2.2

I have a multi-project solution that was working fine in VS2017, I've installed VS2019 and on compile I receive five error messages:
Four of the format: This version of Microsoft.AspNetCore.App is only compatible with netcoreapp2.2 taret framework. Please target netcoreapp2.2 or chose a version of Microsoft.AspNetCore.app compatible with netcoreapp3.1
And one of the format: Project '..\project-path\project.csproj' targets 'netcoreapp3.1;. It cannot be reference by a project that targets '.NETCoreApp,Version=v2.2'
Additionally if you look at the projects referenced in the error messages the Dependencies, Packages, SDK all have the yellow warning symbol on them (hover and right-click don't seem to provide additional details)
I've tried cleans, delete bin and obj folders, rebuilds, checking SDK versions, but no luck
I can confirm I have a global.json with the SDK version (2.2.103) and that when in any of these projects directories and I run 'dotnet --verson' I get back 2.2.103
What is happening here? What / where is it picking up netcoreapp3.1 from and how do I resolve these errors?
Update: CSPROJ Details
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Include="appsettings.json" CopyToOutputDirectory="Always" />
<None Include="favicon.ico" CopyToOutputDirectory="Always" />
<None Include="appDevLocalOverride.json" />
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="3.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.AzureKeyVault.HostingStartup" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
</ItemGroup>
I'm not sure why or how this works, but I have stumbled on a solution:
Open the csproj
Edit <PackageReference Include="Microsoft.AspNetCore.App" /> to <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
Build > Clean Solution
Manually remove ALL bin and obj folders (even if they are only remotely related to the solution)
Build > Rebuild Solution
Edit <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> to <PackageReference Include="Microsoft.AspNetCore.App" />
That seemed to work for me, why a simple Clean Solution and Rebuild wasn't the answer is odd; but hopefully this will help someone else!

dotnet compiler error while publishing f# project

I am trying to publish a dotnet core 2.0.0 (release version) project from command line.
I am getting an error as below.
EXEC(1,1): error CS8301: Invalid name for a preprocessing symbol; '' is not a valid identifier [C:\Work\FloAppGit\FloAppStpl\FloMa
nufacturer\FloManufacturer.fsproj]
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.0\build\netstandard2.0\Microsof
t.AspNetCore.Mvc.Razor.ViewCompilation.targets(60,5): error MSB3073: The command ""C:\Program Files\dotnet\dotnet.exe" exec --runt
imeconfig "C:\Work\FloAppGit\FloAppStpl\FloManufacturer\bin\Debug\netcoreapp2.0\FloManufacturer.runtimeconfig.json" --depsfile "C:
\Work\FloAppGit\FloAppStpl\FloManufacturer\bin\Debug\netcoreapp2.0\FloManufacturer.deps.json" "C:\Program Files\dotnet\sdk\NuGetFa
llbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.0\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilat
ion.dll" #"obj\Debug\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"" exited with code 1. [C:\Work\FloAppGit\Flo
AppStpl\FloManufacturer\FloManufacturer.fsproj]
My project file is as follows.
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk.Web">
<PropertyGroup>
<EnableDefaultCompileItems>False</EnableDefaultCompileItems>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="Controllers/*.fs" />
<Compile Include="FloLogger.fs" />
<Compile Include="Restful.fs"/>
<Compile Include="AppSettingsHelper.fs" />
<Compile Include="DataRecords/BusinessRecords.fs"/>
<Compile Include="DAL/ManufacturerDAL.fs"/>
<Compile Include="DAL/ItemManufacturerDAL.fs"/>
<Compile Include="BAL/ItemManufacturerBAL.fs"/>
<Compile Include="BAL/ManufacturerBAL.fs"/>
<Compile Include="Manufacturer.fs" />
<Compile Include="ItemManufacturer.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="RavenDB.Client" Version="4.0.0-beta-40016" />
<PackageReference Include="Polly" Version="5.1.0" />
<PackageReference Include="Suave" Version="2.0.3.0" />
<PackageReference Include="Suave.AspNetCore" Version="0.3.0" />
<PackageReference Include="Suave.DotLiquid" Version="2.0.3" />
<PackageReference Include="xunit" Version="2.2.0" />
</ItemGroup>
Please help me resolve this issue as I am stuck.
I was able to resolve the issue by commenting these lines in the project file.
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
Also I had to change the header of the project file like this.
<Project Sdk="Microsoft.NET.Sdk.Web">
Delete the obj and bin folders. Do a dotnet clean then dotnet restore.
I was able to publish the code successfully for dotnet core 2.0.0 release version.

How to print visual studio 2017 nuget project reference warnings

Using Visual Studio 2017 Community. My .NetCoreApp 1.1 project has included 2 packages from nuget that are yielding the little yellow warning label. The packages are obviously not loading correctly and I would like to know why.
I have looked in output
I have looked in package manager console
I have built and rebuilt the project
The packages in question are :
Microsoft.AspNetCore.WebSockets (1.0.1)
Microsoft.AspNetCore.WebSockets.Protocol (0.1.0)
Additionally, this is not an issue with my other .NetCore 1.1 project in the same solution.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets.Protocol" Version="0.1.0" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets.Server" Version="0.1.0" />
</ItemGroup>
</Project>

ASP.NET Core WebApp(.NET Core) missing DataAnnotations

Following situation:
I have a .sln with multiple projects (data-access, business-objects, business-logic, web-server).
The Web-Project is an ASP.NET Core Web Application using .Net-Core 1.1 with the individual user account authorization (Identity) and the "WebApplication"-Template.
The rest of the projects is using the .Net-Framework 4.6.2.
Now I am about to remove the DBContext from the web-server and instead use the same as in the data-access-project.
I set up my ApplicationDBContext accordingly and my User entity extends the IdentityUser. I also changed everything in the web-server-project to use the ApplicationDBContext (in my case called WTHListModell).
I also has the references to the projects WTHList.GO (business-objects) and WTHList.DZ (data-access).
Now here comes the problem:
Doing this using the full .NET-Framework for the Web-Server (creating a ".NET-Core Web-Application (.Net-Framework)" ) is successful and works just fine.
With .Net-Core 1.1 I am getting a FileNotFound-Exception regarding "System.ComponentModel.DataAnnotations" whenever I try to either log-in or register a user.
Now I have read, that DataAnnotations isn't compatible with .Net-Core and I also tried to add other NuGet-Packages and Assemblies to the Web-Project.
I don't know what else I can do about that, because I am supposed to use the .NET-Core Framework 1.1 for the Web-Projekt and it keeps on giving me this particular error.
Has anybody got a clue on how to solve this issue?
I have searched for a while now and I haven't found a solution for this yet...
And if it has any relevance: I am using the VS2017 Enterprise RC.
Thanks in advance.
UPDATE
This is the content of the csproj file:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<PropertyGroup>
<UserSecretsId>aspnet-WTHList.Web2-ab5b6dbd-698d-4877-a2b3-6dd9b7a37960</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink.Loader" Version="14.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.0.0-msbuild2-final" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-final" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild2-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WTHList.DZ\WTHList.DZ.csproj" />
<ProjectReference Include="..\WTHList.GL\WTHList.GL.csproj" />
<ProjectReference Include="..\WTHList.GO\WTHList.GO.csproj" />
</ItemGroup>
</Project>
Don't be confused with different "Core" terms: .NET Core is new "base" framework, which "looks like" .NET Framework 4.5 (4.6, etc), but this is other framework. You can compile multiple versions of same project (for different frameworks) at once.
ASP.NET Core is like old ASP.NET, but a new one. It is compiled twice - once for .NET Framework 4.5.1 (and "compatible" 4.5.2, 4.6, 4.6.1) and once for .NET Core (actually, for netstandart1.6 which is some kind of "specification", which is implemented by NET Core).
So, you can create web apps using ASP.NET Core which can build/run on .NET Framework 4.5.1 and/or on .NET Core. But you need all dependencies to be also build on (compatible with) .NET Framework 4.5.1 and/or on .NET Core.
So, if your app require some libraries (e.g. System.ComponentModel.DataAnnotations) which is not available for NET Core - you can't build/run app on .NET Core. You can only build ASP.NET Core app on top of .NET Framework 4.5.1+.

Resources