【问题标题】:VSSDK: can't build solution with mixed style csproj-projects containing VSIX-projectsVSSDK:无法使用包含 VSIX 项目的混合样式 csproj 项目构建解决方案
【发布时间】:2018-04-06 22:54:42
【问题描述】:

我有一个解决方案,其中包含多个针对 net461 和 netcoreapp2.0 的项目。该解决方案还包含带有我的 DslTools 扩展的 VSIX 项目。 VSIX 项目使用旧的 csproj 格式,而其他项目使用新的 csproj 格式 (SDK)。但是所有项目都使用 PackageReference 格式作为 nuget 引用。
所以没有packages.config,没有project.json。

VSIX 项目依赖于Microsoft.VSSDK.BuildTools nuget 包和来自 VSExtensibility 系列的其他包。

对于 DSL 工具,我必须将所需资产从 DSL SDK(建模 SDK)复制到我的项目中并明确引用它们。

解决方案在VS2017中构建就好了。

当我通过 dotnet CLI (dotnet build) 构建它时,出现这样的错误:

D:\..\src\packages\microsoft.vssdk.buildtools\15.5.72\tools\VSSDK\Microsoft.VsSDK.targets(82,5): error MSB4062: The "CompareCommonBuildTaskVersion" task could not be loaded from the assembly D:...\src\packages\microsoft.vssdk.buildtools\15.5.72\tools\VSSDL\Microsoft.VisualStudio.Sdk.BuildTasks.dll. Could not load file or assembly 'System.IO.Packaging, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

可能 dotnet CLI 下的 MSBuild 无法从 VSSDK 加载 Microsoft.VisualStudio.Sdk.BuildTasks.dll。

因此无法使用 dotnet CLI 构建 VSIX 项目。

然后我尝试通过 msbuild.exe 构建。它应该像在 VS 中一样工作,但它没有。

此时我得到:

"D:..\Src\DslDesigner\Dsl\Dsl.csproj" (default target) (2) ->
(ResolveNuGetPackageAssets target) ->
Z:\Prog\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(184,5): error : Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win": { } }' to your project.json and then re-run NuGet restore. [D:...\Src\DslDesigner\Dsl\Dsl.csproj]

根据issue,它在 NuGet 中有点过时了。但这是关于消息而不是错误。

VSIX-csproj 有: 工具版本="15.0" TargetFrameworkVersion=4.6.1

所以我不知道如何在命令行中构建我的解决方案。有什么建议吗?

【问题讨论】:

    标签: .net msbuild visual-studio-2017 vsix vs-extensibility


    【解决方案1】:

    什么有助于解决问题 - 我将以下属性添加到与 VSIX 相关的所有(旧格式)csproj-s 中:

    <RuntimeIdentifiers>win</RuntimeIdentifiers>
    

    【讨论】:

    • 更新我们的 MSBuild 工具后,我们遇到了以下错误:project.json doesn't have a runtimes section, add '“runtimes”: { “win”: { } }' 。这最终解决了我们的问题,没有其他格式或值起作用。 (例如 或使用 win-x86 作为值或任何东西)。干杯!添加此评论,以便其他有相同问题的人可以找到它。
    猜你喜欢
    • 2019-04-22
    • 1970-01-01
    • 2022-07-14
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 2012-03-18
    • 2011-06-05
    • 2013-05-29
    相关资源
    最近更新 更多