Ender Aric
Ender Aric

Reputation: 257

Error CS2001: Source file MyProfile.cshtml.g.cs could not be found

I have a problem with my project which was developed with .net Core SDK 2.2.

It was working but after operating system upgrade (Mac OS X Catalina) my project throws this error for each view pages.

/Users/myUser/Projects/FilterApp/FilterApp.Two/CSC: Error CS2001: Source file 
'/Users/myUser/Projects/FilterApp/FilterApp.Two/obj/Debug/netcoreapp2.2/netcoreapp2.2/
Razor/Views/Home/MyProfile.cshtml.g.cs' could not be found. (CS2001) (FilterApp.Two)

I couldn't resolve this problem after trying many things on the internet.

Here is my SDK List

Upvotes: 0

Views: 2264

Answers (2)

Mats Magnem
Mats Magnem

Reputation: 1405

Try deleting the obj folder, then rebuild the solution.

Upvotes: 1

sopcce
sopcce

Reputation: 19

I have a problem with my net core mvc razor project which was developed with .net Core SDK 2.2.

This problem only appears when dotnet core mvc razor ,my project throws this error for each view pages.

I think the problem is msbuild error.

on window 10, in rider 2019.3 or vs2019, I don't have this problem.

on mac ,in rider 2019.3 or vs2019 ,I have this problem too.

GuodeMacBook-Pro:Code sopcce $ msbuild /version
用于 Mono 的 Microsoft (R) 生成引擎版本 16.3.0-ci
版权所有(C) Microsoft Corporation。保留所有权利。

I've tried to walk around by adding this line to the csproj file and it built successfully.

Don't ask me why,

I don't know.


<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>

my Web.csproj

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <BuildDir>Build</BuildDir>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
  </PropertyGroup>

ps:

Upvotes: 2

Related Questions