What causes the error: The "NgenLocalized" parameter is not supported

What causes the error: The "NgenLocalized" parameter is not supported

我的项目是一个 Visual Studio 扩展。该解决方案包含多个项目并引用多个 NuGet 包。

在构建解决方案时,我遇到了两个错误:

error MSB4064: The "NgenLocalized" parameter is not supported by the "GenerateFileManifest" task. Verify the parameter exists on the task, and it is a settable public instance property.

error MSB4063: The "GenerateFileManifest" task could not be initialized with its input parameters.

完整的错误是:

C:\Users\Phil\.nuget\packages\microsoft.vssdk.buildtools.3.2093\tools\VSSDK\Microsoft.VsSDK.targets(685,88): error MSB4064: The "NgenLocalized" parameter is not supported by the "GenerateFileManifest" task. Verify the parameter exists on the task, and it is a settable public instance property.
C:\Users\Phil\.nuget\packages\microsoft.vssdk.buildtools.3.2093\tools\VSSDK\Microsoft.VsSDK.targets(685,5): error MSB4063: The "GenerateFileManifest" task could not be initialized with its input parameters. 

我在构建发布版或调试版时遇到这些错误。

这些错误是什么意思,我怎样才能摆脱它们?


奇怪的是,如果我只是开始调试,它会在没有错误的情况下构建并启动 visual studio。但是,在那种情况下,我无法加载我的包裹。

activity 日志显示错误:

SetSite failed for package [MultiLanguagePackage]
Source: "MultiLanguageWPF" 
Description: Method not found: "Microsoft.VisualStudio.Threading.JoinableTaskFactory Microsoft.VisualStudio.Shell.AsyncPackage.get_JoinableTaskFactory()".
System.MissingMethodException: Method not found: "Microsoft.VisualStudio.Threading.JoinableTaskFactory Microsoft.VisualStudio.Shell.AsyncPackage.get_JoinableTaskFactory()".
   at MultiLanguageWPF.MultiLanguagePackage.<InitializeAsync>d__2.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at MultiLanguageWPF.MultiLanguagePackage.InitializeAsync(CancellationToken cancellationToken, IProgress`1 progress)
   at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass19_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext()
   --- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)
   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)&#x000D;&#x000A;   at Microsoft.VisualStudio.Services.VsTask.GetResult()</description>

这可能是相关错误,也可能不是。

error MSB4064: The "NgenLocalized" parameter is not supported by the "GenerateFileManifest" task. Verify the parameter exists on the task, and it is a settable public instance property.

error MSB4063: The "GenerateFileManifest" task could not be initialized with its input parameters.

无法在我的机器上重现完全相同的问题,因为我缺少有关您的项目的足够必要信息。但我想这可能是关于 Microsoft.VSSDK.BuildTools16.3.2093 版本的一个问题。

一些测试和发现:

Msbuild 使用目标来管理构建过程。我们可以考虑msbuild target as the group of msbuild tasks。该任务是 MSBuild 用于执行原子生成操作的可执行代码单元。

我打开第 685 行的 Microsoft.VsSDK.targets(版本) 文件,发现以下内容:

  <Target Name="GenerateFileManifest"
          Outputs="$(FileManifest)"
          DependsOnTargets="$(GenerateFileManifestDependsOn)">
    <GenerateFileManifest FileItems="@(VsixSourceItem)" FileManifest="$(FileManifest)" NgenLocalized="$(NgenLocalized)">
      <Output TaskParameter="FileManifest" ItemName="FileWrites" />
    </GenerateFileManifest>
  </Target>

所以很明显,在你的 vsix 项目的构建过程中,它会调用 GenerateFileManifest 目标,而这个目标将调用并执行 GenerateFileManifest 任务。

看到this,我们可以更好地理解what the task means and what it really does for us during build process执行GenerateFileManifest任务实际上类似于从GenerateFileManifest调用方法class。而根据FileItems="xxx" FileManifest="xxx" NgenLocalized="xxx"这三个入参,这个GenerateFileManifestclass应该有三个public属性。 (虽然它实际上没有 public 属性 NgenLocalized 在 GenerateFileManifest class 中定义)

然后 Microsoft.VsSDK.targets 文件中的另一行表明此 class 来自程序集 $(VsSDKCommonAssemblyFile),它实际上是 Microsoft.VisualStudio.Sdk.BuildTasks.dll 在同一文件夹中。 (C:\Users\xxx\.nuget\packages\microsoft.vssdk.buildtools.3.2093\tools\VSSDK\)

<UsingTask TaskName="FindVsixManifest" AssemblyFile="$(VsSDKCommonAssemblyFile)" />

查看这个程序集的结构后,我找不到预期的NgenLocalized public 属性。所以我认为这是问题的根本原因。

建议:

  1. 如果这个问题可以在简单的 vsix 项目中重现,请随时报告这个问题 通过帮助=>发送反馈=>报告问题以报告给开发者社区。

  2. 我认为这个问题来自 16.3.2093 包,Microsoft.VsSDK.targetsMicrosoft.VisualStudio.Sdk.BuildTasks.dll 不完全兼容。所以我认为你可以使用这个包的以前版本。(16.2.3073 或更早版本,在我的机器上我实际使用 16.1.3132 版本并且运行良好)

希望对您有所帮助:)