Build Fails - Have to delete obj folder

Every time I stop and restart my application from the Radzen "IDE", I have to delete the obj folder. Why?

radzen: Generating code ...
radzen: Code generation done in 411ms.
dotnet: C:\Program Files\dotnet\sdk\5.0.401\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(142,5): error MSB3231: Unable to remove directory "obj\Debug\netcoreapp3.1\Razor\". Access to the path '\\?\C:\NextGen\NextGen.GUI\server\obj\Debug\netcoreapp3.1\Razor\Views\Home' is denied. [C:\NextGen\NextGen.GUI\server\project.csproj]

dotnet: 

dotnet: The build failed. Fix the build errors and run again.

I have tried rebooting the machine, so nothing else has this folder under its control, but no good. I always have to delete this folder. It is quite irritating, and takes extra time.

This is definitely not related to Radzen for Angular. Please choose carefully forum category before post.

Well, that was helpful, especially given the lack of a .NET category. Thanks.

Might be a folder permissions issue.
Have you checked/compared the permissions on the parent folders, and also the bin and obj folders?

There are two Blazor categories which you can use (Radzen allows you to create Blazor and Angular applications - there is no .NET option hence the lack of .NET forum category).

There is probably a permission problem as @mumfie suggested. Another reason for this is if another tool (e.g. Visual Studio) is simultaneously building/debugging the same application.

I'm puzzled as to why you think it should be intuitive to go to a Blazor category when I didn't create a Blazor app? This category is Radzen IDE (Angular), I am working on an Angular app (taking over from someone else), and my problem seems to be IDE related, so this seems the most logical category to go to.

As for permissions, the permissions on the obj folder match the permissions on the parent server folder. I occasionally use VS Code to look at source, and make small edits (for example, our email server doesn't have authentication, so I had to delete the user/pass from the app.json file), but that is rare. I also use GitKraken to look at my git repo, but have only actually used it to edit a file once. This morning I started Radzen from a PC restart, and it was the only development based program that was running, and the same issue is present. What puzzles me if it was a permissions issue, is that I (as a local admin user) delete the obj folder, and Radzen has no problem recreating it, but it can't get back into its own folder.

Permissions are authenticated users all but full and special permissions, System and administrators have full control, and Users have read/executed, list folder, and read permissions, just like the parent folder as well as the folder that the project is in. I tried editing the permissions and setting both Users and Authenticated Users to full control, but that didn't make a difference. Is there some other group that the Radzen app needs to have permissions here? That doesn't seem to make sense to me, but I'm grasping straws, as it's been more than a decade since I was a sysadmin and my memory on permissions may be rusty here.

Radzen executes dotnet run. What happens if you do the same from command prompt?

PS C:\NextGen\NextGen.GUI\server> dotnet run
C:\Program Files\dotnet\sdk\5.0.401\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(142,5): error MSB3231: Unable to remove directory "obj\Debug\netcoreapp3.1\Razor\". Access to the path '\\?\C:\NextGen\NextGen.GUI\server\obj\Debug\netcoreapp3.1\Razor\Views\Home' is denied. [C:\NextGen\NextGen.GUI\server\project.csproj]

The build failed. Fix the build errors and run again.
PS C:\NextGen\NextGen.GUI\server>

In this case the problem is with .NET SDK in general. Is the project opened in Visual Studio?

No. VS is open, but no projects are loaded, and this project has never been loaded in it. I am only using it for TFS tasks, and occasionally looking at source while I look for bugs in our other project. I am a new developer, transitioning from QA to dev, and the project I am transitioning away from in QA is in TFS, but the new Radzen project I'm working on is in git.

I tried closing VS, and that made no difference. The only other thing that was open that could even remotely be connected is SQL Server Management Studio, which I also closed and tried again with same results. Only applications open now are Outlook, browser, and Radzen.

Try to kill all dotnet processes before dotnet run to see if this will help: taskkill /f /im dotnet.exe

PS C:\NextGen\NextGen.GUI\server> taskkill /f /im dotnet.exe
ERROR: The process "dotnet.exe" not found.
PS C:\NextGen\NextGen.GUI\server>

I’m afraid that I don’t have any more ideas

Thank you for trying. I'm continuing to search based on it being an issue when dotnet run is tried, but nothing found yet. We'll see.

You can also check this thread which shows various ways to find what process has locked a file or directory: filesystems - Find out which process is locking a file or folder in Windows - Super User

1 Like