I installed Visual Studio 2022 on my laptop, which is a Windows 11 Home Edition. I created a new Angular and ASP.NET Core web application, using all the defaults. When Visual Studio was creating the solution, and again every time I try to run it using the F5 key, I get this error, in a command window:
First command: > angularapp1.client@0.0.0 prestart
Second command: > node aspnetcore-https
Error:
There was an error exporting the HTTPS developer certificate to a file.
This is a fresh install of Visual Studio 2022, and the solution was created using all the defaults, which works perfectly on my Windows 10 PC. It happens even when I run VS as Administrator.
I have tried running these commands:
dotnet dev-certs https --clean
dotnet dev-certs https --trust
But that did not help.
Then I tried running this command:
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p MyPassword
But it said that a valid HTTPS certificate was already present.
I ran this:
dotnet dev-certs https -v
And it found only one valid certificate.
I tried creating a second Angular and ASP.NET Core web application, but got the same error.
I don't know what else to try. Can anyone help?
According to this link, there is a bug in new versions of .NET where the certificate folder is not automatically created.
The workaround is to add the following code in the aspnetcore-https.js file:
const fs = require('fs');
//...
const baseFolder =
//...
fs.mkdirSync(baseFolder, { recursive: true });