asp.net core 3.0 IModelBinder - asp.net-core-3.0

IModelBinder does not get recognized and compile with only asp.net core 3.0 (netcoreapp3.0) installed untill Microsoft.AspNetCore.Mvc.2.2.0 nuget is installed and the version 3.0 nuget is not available for the same.
Is it fine to include 2.2.0 nuget with asp.net core 3.0 app?
Or am I missing something.

I was building a utility class library. Default asp.net core template adds the reference without mentioning it in ItemGroup.
In a class library, adding the below in project file resolves the issue.
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

Related

How to add [ExcludeFromCodeCoverage] attribute at an assembly-level in a .Net Standard 2.1 project

I have a .Net Core application which has got one .Net Standard 2.1 project in it. I am using Coverlet to get the code coverage in Cobertura format.
I am using "coverlet.msbuild" nuget package in all my Test projects.
I want to add [ExcludeFromCodeCoverage] attribute at a assembly-level so that coverlet ignores this project while performing the analysis.
I cannot find AssemblyInfo.cs file in .Net Core / .Net Standard projects.
I tried adding below tag in the proejct's .csproj file
<ItemGroup>
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" />
</ItemGroup>
but still no luck.
The only workaround for me is to add [ExcludeFromCodeCoverage] attribute manually in all the class files which is not a best way.
This worked for .NET 6. I suspect it will work for .NET Core 3.1+
Add the following to the csproj file
<ItemGroup>
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage" />
</ItemGroup>
Or this in any file in the project for the assembly
using System.Diagnostics.CodeAnalysis;
[assembly: ExcludeFromCodeCoverage]

.net core Windows Service Wix install Window service issue : The application to execute does not exist

I am using VS 2019 and .NET Core 3.1.
I have converted windows service to .NET Core 3.1 and tried to create the msi installer using WIX.
I have created the installer, and while trying to start the application I am getting the error like
The application to execute does not exist: 'C:\Program Files (x86)\DRAProcessorServiceFolder\Django_DRAProcessorService.dll'.
My product.wxs code is below
<File Id="Django_DRAProcessorService" Name="Django_DRAProcessorService.exe" Source="..\Django_DRAProcessorService\bin\Release\netcoreapp3.1\win10-x64\Django_DRAProcessorService.exe" Vital="yes" KeyPath="yes" />
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="WorkingService2"
DisplayName="Django_DRAProcessorService"
Description="Django_DRAProcessorService"
Account="NT AUTHORITY\LocalService"
Start="auto"
Interactive="no"
ErrorControl="normal"
/>
<ServiceControl
Id="ServiceInstaller"
Start="install"
Stop="both"
Remove="uninstall"
Name="Django_DRAProcessorService"
Wait="yes" />
If anybody knows any solution please help me.

How to force Swashbuckle.Aspnetcore.Cli to use netcoreapp3.1?

I'm upgrading a project to use .Net Core 3.1 from 2.2, and am struggling with getting my tools working.
I have this section in my .csproj file which generates a swagger.json file at publish time - it gets executed in our build pipeline and published as an artifact.
<ItemGroup>
<DotNetCliToolReference Include="Swashbuckle.AspNetCore.Cli" Version="5.2.1" />
</ItemGroup>
<Target Name="Swagger" AfterTargets="PrepareForPublish" DependsOnTargets="Build" Outputs="$(PublishDir)swagger.json">
<Exec Command="dotnet swagger tofile --output $(PublishDir)swagger.json $(OutputPath)\$(AssemblyName).dll v1" />
</Target>
But I'm getting these errors:
Package Swashbuckle.AspNetCore.Cli 5.2.1 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Package Swashbuckle.AspNetCore.Cli 5.2.1 supports:
- netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any
- netcoreapp3.0 (.NETCoreApp,Version=v3.0) / any
and:
Invalid project-package combination for Swashbuckle.AspNetCore.Cli 5.2.1. DotnetToolReference project style can only contain references of the DotnetTool type
The weird thing is that my project is using 3.1 - I did a ctrl+f on both "netcoreapp2.2" and "2.2" and couldn't find anywhere that was being specified. How can I force my CLI tool to use the correct .NET Core version?
I had the same problem and resolved it by following the installation steps described here: https://github.com/domaindrivendev/Swashbuckle.AspNetCore#retrieve-swagger-directly-from-a-startup-assembly, and by removing the ItemGroup of the project file:
<ItemGroup>
<DotNetCliToolReference Include="Swashbuckle.AspNetCore.Cli" Version="5.2.1" />
</ItemGroup>
I had the same issue when trying to use dotnet swagger. I switched to using just swagger and that fixed the issue. And as #Mike said, remove the ItemGroup from the project file and install the cli globally as outlined here: https://github.com/domaindrivendev/Swashbuckle.AspNetCore#retrieve-swagger-directly-from-a-startup-assembly

How to find exact version selected by nuget for a PackageReference?

I can refer NuGet packages in .NET Core using
<PackageReference Include="ExamplePackage" Version="6.*" />
How to find the exact version of ExamplePackage used during the build?

use Swagger in dot net core api framework 2

How to use Swagger in asp.net core API.
i used core framework-2.
i try
Swashbuckle.AspNetCore
package, but it's not supported in framework-2.
I had the same issue and could be able to fix it by installing Microsoft.AspNetCore.StaticFiles Nuget package.
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/438

Resources