Error scaffolding identity in blazor webassembly app - asp.net

I am building a webassembly project in Razor using Visual Studio 2019 (version 16.9.4) and whenever I try to scaffold the identity I get an error saying that a package restore did not work, and everything is rolled back.
My question is twofold:
How do I solve this error?
Are there any alternatives to the scaffolding of the identity?
Grtz,
Iede Snoek

There is an offical page about this but I found it a little confusing. The Blazor WebAssembly UI is not supported, that makes sense. But the Hosted variation should be just like a Blazor Server project. I think that is what is being said there and that makes sense.
But whewn I gave it a try I got the same error as you did, with packages getting rolled back. And no info on what packages.
So I gave Blazor Server a go, and I kept a watch on the changes. The scaffolding worked and it downgraded some packages from 5.0.5 to 5.0.4 .
After editing the MyProject.Server.csproj the same way scaffolding worked like a charm. The "Manage Packages" UI did not work and I did have to Clean the solution first.
The altered parts of my csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
...
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server"
Version="5.0.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design"
Version="5.0.2" />
</ItemGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore"
Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore"
Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI"
Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer"
Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer"
Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"
Version="5.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
The small version steps make me think this is a very temporary problem.

Related

How do I update other Microsoft libraries after updating to .Net Core 3.1

I have a web app solution that is quite old where the main project is Asp.Net 4.6 and a small companion project is .Net Core 2.
I want to first upgrade them both to .Net Core 3.1, and then upgrade to .Net 7 later this year.
According to the Microsoft documentation I have to update the target framework and associated libraries.
So I updated this part in my project file:
<TargetFramework>netcoreapp3.1</TargetFramework>
However, the other referenced libraries don't seem to have 3.1 updates. How would I upgrade these?
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.3.0" />
<PackageReference Include="System.ServiceModel.Security" Version="4.3.0" />
Thanks!
When Microsoft introduced .NET Core 3.0, they stopped producing a large number of NuGet packages (If you're interested, you can see the list here).
Microsoft made them part of the shared framework Microsoft.AspNetCore.App that is implicitly referenced if your .csproj targets Microsoft.NET.Sdk.Web SDK. You can check this in your .csproj project.
<Project Sdk="Microsoft.NET.Sdk.Web">
...
</Project>
If your project targets Microsoft.NET.Sdk, then you might have to add a FrameworkReference, as explained here.
Assuming the latter is not your case, removing the references to those NuGet packages should be fine.
For microsoft .net core packages,I think you could search in the document and found the correspond packages.
https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore?view=aspnetcore-2.2
example1:
example2:

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!

Process creation failed with error: Access is denied when starting project in debug mode

I have an ASP.NET Core project targeting net4.6.1
The following error is thrown every time I try to start the project with debugging, from both VS2017 and command line using dotnet run.
The csproj is the following:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Platforms>x64</Platforms>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
<StartupObject></StartupObject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\pathToAnotherProject\myproject.csproj" />
</ItemGroup>
</Project>
I can mention that I have a single startup project created as an ASP.NET Core project and multiple .net core class library projects targeting net461.
Any idea where the problem comes from?
Have you tried to enable 'use managed compatibility mode' in the debugging>general section of VS2017 options.

Reference XtraReport in Dotnet Core application

I would like to create a dotnet core console application that should create pdf report using DevExpress XtraReport.
How can I reference the devexpress dll in my csproj?
Thanks a lot
EDIT:
the project targets net462
This is my csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot/" />
</ItemGroup>
<ItemGroup>
<Content Include="Properties/**">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="tempkey.rsa">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
Refer this - Reporting support for .Net core
It's hard to speak about possible estimates here as NET Core 2.0 does
not support System.Drawing, Sörnt. Right now, everything that is
available in .NET Standard 2.0 is a few drawing primitives, that's all
(see diff). On the other hand, implementing a custom drawing library
that would work for any possible target .NET platform is a very
complex task — I'd say it's just as hard as doing a new reporting
engine from scratch. Yes, there are some alternatives for drawing
(e.g., Mono's gdipluslib), but they have a lot of compatibility issues
we need to deal with, not to mention that some areas (like the actual
printing) are not covered at all. Of course, being compatible with the
.NET Standard is something is that we look forward to, but there are
still missing pieces our engine heavily relies on. Needless to say,
the .NET Core development is moving really fast comparing to the
legacy .NET Framework, so it's highly possible that we'll see more and
more features / APIs provided by the corefx team very soon.
It is not yet supported in .net core apps. There may be some workaround to use in asp.net core applications.. See below reference links.
References:
XtraReports in .NET Core
XtraReports for ASP.NET Core
Reporting support for .Net core
XtraReports does support the dotnet core platform starting with v18.1.
https://community.devexpress.com/blogs/reporting/archive/2018/04/26/reporting-net-core-support-ctp-v18-1.aspx
https://docs.devexpress.com/XtraReports/119717/create-end-user-reporting-applications/web-reporting/aspnet-core-reporting

newtonsoft.json 9.0.1 not compatible with netcoreapp1.1 in newly created Visual Studio Project

I created a new ASP.NET Core Web Application in Visual Studio 2017 and immediately got the following error:
Restoring NuGet packages...
Package Newtonsoft.Json 9.0.1 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Newtonsoft.Json 9.0.1 supports:
- net20 (.NETFramework,Version=v2.0)
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
- netstandard1.0 (.NETStandard,Version=v1.0)
- portable-net40+sl5+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile328)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
NuGet package restore failed.
It seems that Newtonsoft.Json is not compatible with netcoreapp, but why would VisualStudio include it if that is the case? I'm pretty new to ASP.NET so maybe there is something I am missing? I followed the steps from the ASP.NET Core Docs.
While searching I found some similar issues, but none seem to be compatible with VS 2017.
Also here is my .csproj file if it helps:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
</Project>
Ok, I just reinstalled Visual Studio, repaired it from the installer and cleared the NuGet Cache and now it's working. Seems like something wasn't setup correctly.

Resources