英文:
Release Build Fails on Docker Publish MSB4803
问题
The task "ResolveComReference" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See here for further details.
英文:
I am trying to publish a .NET Core 6 Blazor Server project to Portainer. I can build and run the project fine in Debug, however when I try Release or to publish the project the build fails giving me the following.
> error MSB4803: The task "ResolveComReference" is not supported on the
> .NET Core version of MSBuild. Please use the .NET Framework version of
> MSBuild. See https://aka.ms/msbuild/MSB4803 for further details.
> [/src/Necon/Necon.csproj]
The output of the entire build attempt is:
------
> [build 7/7] RUN dotnet build "Necon.csproj" -c Release -o /app/build:
#15 2.489 All projects are up-to-date for restore.
#15 3.000 /usr/share/dotnet/sdk/6.0.408/Microsoft.Common.CurrentVersion.targets(2927,5): error MSB4803: The task "ResolveComReference" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/msbuild/MSB4803 for further details. [/src/Necon/Necon.csproj]
#15 3.007
#15 3.007 Build FAILED.
#15 3.007
#15 3.007 /usr/share/dotnet/sdk/6.0.408/Microsoft.Common.CurrentVersion.targets(2927,5): error MSB4803: The task "ResolveComReference" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/msbuild/MSB4803 for further details. [/src/Necon/Necon.csproj]
#15 3.007 0 Warning(s)
#15 3.007 1 Error(s)
#15 3.007
#15 3.007 Time Elapsed 00:00:01.90
------
WARNING: buildx: git was not found in the system. Current commit information was not captured by the build
Dockerfile:14
Most of my googling brings me to this answer https://stackoverflow.com/questions/62577989/error-msb4803-the-task-resolvecomreference-is-not-supported-on-the-net-cor however it nearly 3 years old. I have also tried this article with no success.
My docker file is:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Necon/Necon.csproj", "Necon/"]
RUN dotnet restore "Necon/Necon.csproj"
COPY . .
WORKDIR "/src/Necon"
RUN dotnet build "Necon.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Necon.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Necon.dll"]
Mr Necon.csproj is:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>8ac9eb75-ec3e-42b0-b702-405a8e375b34</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
</PropertyGroup>
<ItemGroup>
<COMReference Include="DecklinkPublicLib">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>1469d378-8829-4ff0-9b3b-07dd5b16f3cb</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
<COMReference Include="BMDSwitcherAPI">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>8a92b919-156c-4d61-94ef-03f9be4004b0</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.13" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.11" />
<PackageReference Include="MudBlazor" Version="6.1.8" />
</ItemGroup>
</Project>
My dockerignore file is:
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
答案1
得分: 0
以下是您要翻译的内容:
我相信与下面的COMReference相关的问题,我已经进行了研究,DecklinkPublicLib
似乎可以在Linux中使用,但BMDSwitcherAPI
不能。
所以,您可以在您的.csproj文件中注释它并尝试一下。
提示
在您注释它之后,您需要尝试在本地编译它,然后部署它。
解决方法
使用Windows平台,而不是Linux。
<COMReference Include="DecklinkPublicLib">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>1469d378-8829-4ff0-9b3b-07dd5b16f3cb</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
<COMReference Include="BMDSwitcherAPI">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>8a92b919-156c-4d61-94ef-03f9be4004b0</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
请注意,这是您要翻译的部分,不包括其他内容。
英文:
I believe the issue related to below COMReference, I have researched, and DecklinkPublicLib
seems can be used in linux, but BMDSwitcherAPI
can't.
So you can comment it in your .csproj file and give it a try.
Tips
After you comment it, you need to try to complie it in your local, then deploy it.
Workaround
Using windows-platform, not linux.
<COMReference Include="DecklinkPublicLib">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>1469d378-8829-4ff0-9b3b-07dd5b16f3cb</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
<COMReference Include="BMDSwitcherAPI">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>8a92b919-156c-4d61-94ef-03f9be4004b0</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论