相关疑难解决方法(0)

错误 MSB4801:.NET Core 版本的 MSBuild 不支持任务工厂“CodeTaskFactory”

我的项目.Net 6中有一个UsingTask。我有一个小脚本来使用CodeTaskFactory设置AssemblyVersion。请参阅下面的代码。但是,我无法使用 MS Build 在构建服务器上使用或执行 CodeTaskFactory。

它给出了这些错误:

Error MSB4801: The task factory "CodeTaskFactory" is not supported on the .NET Core version of MSBuild
Error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files\dotnet\sdk\6.0.101\Microsoft.Build.Tasks.Core.dll". The task factory must return a value for the "TaskType" property
Run Code Online (Sandbox Code Playgroud)

我研究了其他一些选择,但都失败了,因为它们缺少一件事或另一件事。所以最后我在这里问,在 MS Build 服务器上运行带有输出的 usingTask 有哪些选项?

我的代码

  <UsingTask TaskName="mytask"    
      TaskFactory="CodeTaskFactory"
      AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
    <ParameterGroup>
      <AssemblyVersion ParameterType="System.String" Output="true" />
    </ParameterGroup>
    <Task>
      <Code Type="Fragment" Language="cs">
        <![CDATA[
          Log.LogMessage(MessageImportance.High, "we are here");
          AssemblyVersion = "1.2.3.4";
        ]]>
      </Code> …
Run Code Online (Sandbox Code Playgroud)

c# msbuild .net-6.0

6
推荐指数
1
解决办法
4446
查看次数

标签 统计

.net-6.0 ×1

c# ×1

msbuild ×1