简体   繁体   中英

Visual Studio 2019 ASP.NET Core API project template broken?

I'm trying to add an ASP.NET Core 3.0 RESTFUL service project (using the API template) to an existing UWP solution. When I add the service project, this is what shows up in VS2019 (16.3.6, since updated to the latest preview release to see if that helped). Project files and folders not displayed

Project properties are captured in the grab below: Project Properties screen capture

The template is generating the files from the template correctly. Root folder contains these files:

----                -------------         ------ ----
d-----       27/10/2019   1:07 AM                bin
d-----       27/10/2019   1:07 AM                Controllers
d-----       27/10/2019   2:58 AM                obj
d-----       27/10/2019   1:07 AM                Properties
-a----       27/10/2019   1:07 AM            146 appsettings.Development.json
-a----       27/10/2019   1:07 AM            192 appsettings.json
-a----       27/10/2019   1:07 AM            717 EPCSServices.csproj
-a----       27/10/2019   1:07 AM            720 Program.cs
-a----       27/10/2019   1:07 AM           1464 Startup.cs
-a----       27/10/2019   1:07 AM            308 WeatherForecast.cs

And the Controllers folder contains this file, which gets installed by the template:

----                -------------         ------ ----
-a----       27/10/2019   1:07 AM           1185 WeatherForecastController.cs

But VS2019 is not allowing me to edit them within the IDE. I've tried cleaning the project and solution, and also unloading/reloading the project. I've tried updating the nuget packages using -includePrerelease and installed all the latest .NET Core binaries (including ASP.NET Core, EF Core, NewtonSoft.json, etc). All to no avail. The solution won't build. After build, it throws a single error as per below:

Error NETSDK1004    
Assets file '<Path>\EPCSServices\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. 
EPCSServices    
C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets
Line 234        

I've done the NuGet package restore using the UI. Obj folder and relevant.json file exist.

VS2019 has also thrown various messages in the output window about the Microsoft.VisualStudio.Web.CodeGeneration.Design nuget package - again updated without luck.

I've tried this using .NET Core 3.0, .NET Core 3.1 (preview), even .NET Core 2.2. Am I unique in having experienced this since the 16.3.6 drop on Friday? I'd like to finish setting up this solution so I can start work coding in anger over the next day or so.

I found out what the problem was. My project was being loaded into a folder containing HTML escape characters as I had spaces in the Azure DevOps project which I cloned the empty repository from.

I confirmed this in a folder that wasn't git-managed and had no special character codes - project unpacked properly as you'd expect.

I then double-confirmed the offending behaviour by creating a folder with an escape-coded space in the folder name, then boom - template build crashed.

So... moral of the story - don't put spaces in your Azure DevOps projects that will end up getting cascaded down to your local repo when you're working on ASP.NET projects. Also... it's kind of amazing that this didn't end up being a better documented problem given how simple it turned out to be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM