cofoundry-cms / cofoundry

Cofoundry is an extensible and flexible .NET Core CMS & application framework focusing on code first development

Home Page:https://www.cofoundry.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing source file

irdublu opened this issue · comments

I have just downloaded the latest SimpleSite sample from GitHub.
As per Readme.md, I did item 1 and created a database.
I then failed at item 2 and could not build the site so cannot run it.

I get error code CS2001 "Cofoundry.Samples.SimpleSite-master\src\Cofoundry.Samples.SimpleSite\obj\Debug\netcoreapp3.1\Razor\Cofoundry\PageBlockTypes\ContentSplitSection\Templates\ContentSplitSectionReverse.cshtml.g.cs' could not be found."

I also get error code MSBB3231 "Unable to remove directory "obj\Debug\netcoreapp3.1\Razor". Could not find a part of the path 'ContentSplitSectionReverse.cshtml.g.cs'."

I have closed the solution, deleted the .vs file and the bin and obj folders, then reloaded the solution but always the same issue.

I have not made any changes to any code. It is the auto-generated code that is flagging up the issue.

I am using Visual Studio 2019 with .Net Core 3.1 and SQL Server 2019 (150)

Any ideas as to what is going wrong?

Hi there, I've just re-cloned the sample and ran it from scratch on my machine and it works (VS 2019 (16.11.10) / .NET Core 3.1 latest build) so I think that rules out any obvious issues. I've had a look at the error codes but can't seem to find anything relevant. It does seem like an odd error, perhaps some kind of file-access issue. Have you tried re-cloning and re-starting Visual Studio?

Is there any other console output that might indicate a different issue? Or perhaps do you have any VS plugins installed that might be conflicting?

Hi, thanks for quick reply. I didn't say but I used the zip file so I haven't cloned it. Is it possible there is a difference between them? No extensions out of the ordinary in my VS. Output shows nothing not already in the error message.

Sorry but I now realise I am using VS 2022 Version 17.0.4.

I did have a go at making a demo project back in August 2021 and it worked but using VS 2019. I kept the solution code and it still runs OK.

Anything here to give you any clues?

I wouldn't expect the zip to be any different. I've not got around to installing 2022 yet, but it could well be something to do with that as I think there is a lot that's changed with razor compilation, it's not accidentally targeting a later version of .NET is it? It's odd that your old demo code works fine in 2022 but the sample doesn't.

My plan was to get 2022 installed after the v0.10 release in prep to target .NET 6, hopefully that's a couple of weeks away.

Here is my project file code. Definitely 3.1 and I don't know how else to check it isn't targeting .net 6

netcoreapp3.1 false false
<PackageReference Include="Cofoundry.Plugins.ErrorLogging.Admin" Version="0.9.0" />

<PackageReference Include="Cofoundry.Plugins.Imaging.SkiaSharp" Version="0.3.1" />
<PackageReference Include="Cofoundry.Web.Admin" Version="0.9.2" />

`

I started a .net Core 3.1 MVC project.

I do have a version of your original zip file from last summer but it looks quite different to the current one so I am concerned I may have changed files in it. Anyway, I will see if I can use it instead of your current one.

I found an original of the 2021 zip file in my backups, extracted it, built it and ran it. It works. Of course, it doesn't have the latest changes you've made but at least I can experiment again..

I installed VS2022 to try and replicate the issue but didn't run into it. I've also been using it for the last week to upgrade all the project and haven't run into any issues either. All samples have now been updated to v0.10 so I'm closing this for now.

If it comes up again with the updated samples let me know.

I have the answer to this error code MSBB3231 "Unable to remove directory "obj\Debug\netcoreapp3.1\Razor". Could not find a part of the path 'ContentSplitSectionReverse.cshtml.g.cs'."

It is not directly a Cofoundry issue but you might wish to know of the cause, as it might easily happen to other developers who might get frantic as I did, being unable to build the system and run it; development came to a complete halt.

I spent days searching for answers but although many people reported it, there was no clear answer, not even from Microsoft. Experimenting with excluding folders from the project gave a clue.

The error is caused by a path that is too long and will randomly work through any files with a path that is too long and never go away until the path is shortened.

I tell you all this because some of the Cofoundry paths are quite long especially when using splitcontent files. My folder path was long to start with so when working with yours, the system couldn't cope.

I do not know if this appears solely in Visual Studio or if it is a Windows issue.

@irdublu thanks for posting this, that's really helpful. It sounds like you're saying that it's a path length issue rather than specifically a file name length issue. Do you have an idea of what the limit is, or what your path length is that exceeds it?

This does ring a bell, I had a look and it does seem there is a 260 character limit on paths on Windows through some APIs, so I guess it's something to do with that. The limit can be disabled via the registry but you probably don't want to do that just to run Cofoundry.

On my configuration path to that file is 143 characters or when copied to obj the path is 197, so it's feasible you could hit that limit. In the next version we're moving to .NET 6 and the new source generators features will hopefully mean that we don't need to copy view files over to the output folder - in that way you would hopefully hit the limit in VS/Filesystem and not get the error during compilation.

Yes, my verbose post is saying it is a fullpath length issue, especially when 'reverse' is added.
No, I do not know the maximum length but you figures are probably right.
I'm very surprised this explanation does not appear in answers on MS forums and Stack Overflow etc.