RazorGenerator
RazorGenerator copied to clipboard
Support for Visual Studio 2022 and .NET 6 & 7 projects?
I'm here to ask - will the tool be supported going forward in Visual Studio 2022? It was actually working for me before, but the latest update to 17.7.3 seems to have finally broken it. It appears the preprocessor tool cannot be run anymore on my .cshtml files meaning I don't have updated html.
If you use the RazorGenerator.MsBuild version instead of the extension, it still works.
And you can use my project MSBuild.SDK.SystemWeb to use SDK projects for Razor Class Libraries and for the ASP.NET 4.x Head project. There are examples and templates available to show it working. If there is a problem with 17.7.3 with the SDK, please let me know.
Some advantages of using the MSBuild package and/or the SDK, are that you don't need to ensure that the extension is installed, you don't need to check-in the compiled code, and a build server can generate the compiled pages too.
Your RazorGenerator.MsBuild suggestion saved my butt! And you're right, it's a far more elegant solution. Just rebuild the project and the file is there to use. Thank you!
@UnreachableCode Glad to be of help. I love this project, and have been using it for years, so I have a lot of tricks and tips for it.
One last thing (I hope). I'm seeing this in our Azure Pipeline on various build tasks/scripts. I know it spells out the problem fairly well, but what am I actually supposed to do? Install Microsoft.Build.Utilities as a package?
C:\Users\VssAdministrator\.nuget\packages\razorgenerator.msbuild\2.5.0\build\RazorGenerator.MsBuild.targets(44,9): error MSB4062: The "RazorCodeGen" task could not be loaded from the assembly C:\Users\VssAdministrator\.nuget\packages\razorgenerator.msbuild\2.5.0\build\\..\tools\RazorGenerator.MsBuild.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\a\1\s\DeepBlue.UI.Minerva\DeepBlue.UI.Minerva.csproj]
DeepBlue.Core.Data.Minerva.EfCore -> D:\a\1\s\DeepBlue.Core.Data.Minerva.EfCore\bin\Debug\net7.0\DeepBlue.Core.Data.Minerva.EfCore.dll
@UnreachableCode Are you trying to build using dotnet build? If you build with the VSBuild task I don't think you should hit that error.
I think that worked. Thank you once again!