【发布时间】:2021-08-17 03:46:40
【问题描述】:
升级到 .NET 6 Preview 7(从 Preview 5 开始)后,我在尝试构建时出现以下错误:
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]
每行实际上都带有前缀:/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 : ,我将其删除以使其更具可读性。
似乎有一个“Razor”任务正在生成一个文件。我不使用 Razor(不过我确实使用 Blazor) - 我怎样才能阻止这种情况发生?
如果我不能禁用它,我该如何设置它在 Directory.Build.props 中使用的目录?
对于上下文,这是发生这种情况的 .fsproj 文件:
<?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>
【问题讨论】:
标签: asp.net .net razor razorgenerator .net-6.0