我有一个解决方案,其中包含多个项目,目标为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)进行构建时,会出现以下错误:
因此没有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。
因此,VSIX项目无法使用dotnet CLI进行构建。
然后我尝试通过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]
根据问题,这是NuGet中已经过时的信息。但这只涉及到消息而非错误。
VSIX-csproj文件具有以下内容: ToolsVersion="15.0" TargetFrameworkVersion=4.6.1
因此,我不知道如何在命令行中构建我的解决方案。有什么建议吗?
project.json没有一个runtimes段,请添加 '“runtimes”: { “win”: { } }'
。最终这解决了我们的问题,没有其他格式或值能够起作用(例如:<RuntimeIdentifier>或使用win-x86作为值或任何其他内容)。干杯!添加此评论以便其他遇到相同问题的人可以找到它。 - Lauw