【问题标题】:What causes the error: The "NgenLocalized" parameter is not supported导致错误的原因:不支持“NgenLocalized”参数
【发布时间】:2019-12-21 08:21:18
【问题描述】:

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

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

错误 MSB4064:“NgenLocalized”参数不受 “生成文件清单”任务。验证任务上是否存在参数, 它是一个可设置的公共实例属性。

错误 MSB4063:无法执行“GenerateFileManifest”任务 用它的输入参数初始化。

完整的错误是:

C:\Users\Phil\.nuget\packages\microsoft.vssdk.buildtools\16.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\16.3.2093\tools\VSSDK\Microsoft.VsSDK.targets(685,5): error MSB4063: The "GenerateFileManifest" task could not be initialized with its input parameters. 

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

这些错误是什么意思,我该如何消除它们?


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

活动日志显示错误:

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>

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

【问题讨论】:

  • 尝试使用其他版本的 nuget 包。也许这个问题就是由此造成的。
  • 仅供参考。运行时错误“SetSite failed for package”是一个不同的错误,但略有相关。为了解决冲突,我添加了对 Microsoft.VisualStudio.Threading 6.3.13 的引用。将 Microsoft.VSSDK.BuildTools 降级到 16.2.3073 后,我还能够删除对 Microsoft.VisualStudio.Threading 的引用(不会产生冲突),并且“SetSite failed”错误也消失了。
  • 有用的信息,谢谢:)

标签: visual-studio msbuild nuget visual-studio-extensions


【解决方案1】:

错误 MSB4064:“NgenLocalized”参数不受 “生成文件清单”任务。验证任务上是否存在参数, 它是一个可设置的公共实例属性。

错误 MSB4063:无法执行“GenerateFileManifest”任务 用它的输入参数初始化。

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

一些测试和发现:

Msbuild 使用目标来管理构建过程。我们可以将msbuild target 视为msbuild tasks 的组。任务是 MSBuild 用来执行原子构建操作的可执行代码单元。

我在第 685 行打开了Microsoft.VsSDK.targets(version) 文件,发现以下内容:

  <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 类中的方法。而根据FileItems="xxx" FileManifest="xxx" NgenLocalized="xxx"这三个输入参数,这个GenerateFileManifest类应该有三个public属性。 (虽然它实际上没有在 GenerateFileManifest 类中定义公共属性 NgenLocalized)

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

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

查看此程序集的结构后,我找不到预期的 NgenLocalized 公共属性。所以我认为这是问题的根源。

建议:

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

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

希望对你有帮助:)

【讨论】:

  • 神奇的兰斯,你对我帮助太大了。我仍然遇到运行时问题,但是(如果我无法修复它)我将把它作为一个单独的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-27
  • 2012-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多