'Angular and .Net Core Project VS 2022: An unhandled exception occurred: Project 'Leon\AppData\Roaming\ASP.NET\https\<projectName>.pem' does not exist
Hello I am building an Angular/.Net Core project and creating the projects by following Microsoft's suggestion, https://docs.microsoft.com/en-us/visualstudio/javascript/tutorial-asp-net-core-with-angular?view=vs-2022. I created one on my laptop which starts without a problem and one on my PC which fails. The key difference and what I suspect to be the problem is that my username on my PC has a space,"Eric Leon", while on my laptop is "eric.leon" but I can't figure out how to fix it. I searched articles and made sure that everything looked good on the angular.json and package.json files. This is the Error
The error log does not contain more relevant information than the output. Notice how the Project starts with Leon\AppData\...
instead of C:\users\Eric Leon\...
and this is why I suspect the username is the problem, because it looks like its cutting of the path at the space in the username. I also looked at the aspnetcore-https.js which seems to be building the path and even replaced the baseFolder
with a hardcoded path with that contained %20 in the name const baseFolder = 'C:/Users/Eric%20Leon/AppData/Roaming/ASP.NET\https'
.
After hours of looking at this I haven't had success so far so any help would be appreciated
Solution 1:[1]
In package.json the start path for the .pem file and the .key file is specified.
"ng serve --ssl --ssl-cert %APPDATA%\\ASP.NET\\https..."
--ssl-cert should contain *C:\Users* and %APPDATA% should contain username\APPDATA\Roaming but in this case --ssl-cert included the first part of my username (firstname) and %APPDATA% started from the second part of the username (lastname). The solution was to put double quotes around %APPDATA% since command line tools only support double quotes and escape them with backslash since its in a json file.
so "ng serve --ssl --ssl-cert \"%APPDATA%\"\\ASP.NET\\https..."
Prior to that I was working around the issue by putting the files in a folder on the C drive and hardcoding the path.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | eleon |