How do I disable Razor tasks in .NET 6?

1.8k views Asked by At

After upgrading to .NET 6 Preview 7 (from Preview 5), I have the following error when I try to build:

System.IO.DirectoryNotFoundException: Could not find a part of the path '/home/dark/app/fsharp-backend/Build/obj/ApiServer/Debug/net6.0/StaticWebAssets.build.json'. [/home/dark/app/fsharp-backend/src/ApiServer/ApiServer.fsproj]
    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) in System.Private.CoreLib.dll:token 0x60000d5+0x0 
    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) in System.Private.CoreLib.dll:token 0x60000d9+0x31 
    at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) in System.Private.CoreLib.dll:token 0x6005cf1+0xe [/home/dark/app/fsharp-backend/src/ApiServer/ApiServer.fsproj]
    at System.IO.File.WriteAllBytes(String path, Byte[] bytes) in System.Private.CoreLib.dll:token 0x6005cc2+0x2b [/home/dark/app/fsharp-backend/src/ApiServer/ApiServer.fsproj]
    at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.PersistManifest(StaticWebAssetsManifest manifest) in Microsoft.NET.Sdk.Razor.Tasks.dll:token 0x600018a+0x3b     at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.Execute() in Microsoft.NET.Sdk.Razor.Tasks.dll:token 0x6000187+0xeb [/home/dark/app/fsharp-backend/src/ApiServer/ApiServer.fsproj]
 Could not find a part of the path '/home/dark/app/fsharp-backend/Build/obj/ApiServer/Debug/net6.0/StaticWebAssets.build.json'. [/home/dark/app/fsharp-backend/src/ApiServer/ApiServer.fsproj]

Each line was actually prefixed with: /usr/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(425,5): error : , which I removed to make it more readable.

It seems there is a "Razor" task which is generating a file. I do not use Razor (I do use Blazor though) - how can I disable this from happening?

If I can't disable it, how can I set the directory that it uses in Directory.Build.props?

For context, here's the .fsproj file where this happens:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <LangVersion>5.0</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <None Include="paket.references" />
    <Compile Include="Middleware.fs" />
    <Compile Include="Login.fs" />
    <Compile Include="Api/APIOps.fs" />
    <Compile Include="ApiServer.fs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="../LibExecution/LibExecution.fsproj" />
    <ProjectReference Include="../LibBackend/LibBackend.fsproj" />
  </ItemGroup>
  <Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>

1

There are 1 answers

0
Paul Biggar On

Turns out this was a bug in Preview 7 that's fixed in RC1: https://github.com/dotnet/aspnetcore/issues/29893