visual studio "Error 102: The "___ 中的构建错误“找不到任务。”

Build error in visual studio "Error 102: The "___" task was not found."

我正在使用 visual studio,但在构建我的项目时遇到了问题。我不确定如何修复它。

我收到这个错误:

Error   289 The "CreateProjectReferenceDefineConstants" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Windows\Microsoft.NET\Framework\v4.0.30319" directory.    C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\wix2010.targets   1279    6   ProcedureManagerSetup

我双击这个错误,这让我找到了这段代码:

  <Target
    Name="AddProjectReferenceDefineConstants"
    Condition=" '@(_ResolvedProjectReferencePaths)' != '' ">

    <CreateProjectReferenceDefineConstants
      ProjectReferencePaths="@(_ResolvedProjectReferencePaths)"
      ProjectConfigurations="$(VSProjectConfigurations)">

      <Output TaskParameter="DefineConstants" PropertyName="ProjectReferenceDefineConstants" />
    </CreateProjectReferenceDefineConstants>
  </Target>

具体是指那一行:

<CreateProjectReferenceDefineConstants

自从我的 windows 10 更新后,就发生了这种情况。我注意到之前,它使用的是 .NET 3.5 。更新后,它变成了.NET 4.0。我不确定这是否是发生这种情况的主要原因,但值得一提。

您在注册表中添加跟随键。

打开 regedit(您在 运行 收件箱中输入了 regedit)

然后您找到 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application 文件夹

并添加新文件夹。

Your new folder name: “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\ASP.NET 4.0.30319”

这解决了我的问题:

  1. 打开en_visual_studio_professional_2012_x86_dvd_920779
  2. 按修复
  3. 打开VS2012.5
  4. 按修复
  5. 卸载并安装wix2010
  6. 重启电脑