问题描述
我正在尝试配置GitHub工作流程,以构建我的多目标NuGet包(与Xamarin.Forms一起使用)并将该包推送到GitHub和Nuget。我讨论了问题here,这似乎可以归结为以下内容:
我无法在工作流程中使用dotnet pack
,导致出现以下错误:
C:\Users\user\.nuget\packages\msbuild.sdk.extras\2.1.2\Build\Workarounds.targets(27,5): error : If you are building projects that require targets from full MSBuild or MSBuildFrameworkToolsPath,you need to use desktop msbuild ('msbuild.exe') instead of 'dotnet build' or 'dotnet msbuild' [C:\path\to.csproj]
当我使用MSBuild(在计算机上手动或通过工作流)时,仅UWP声明可用,并且适用于所有目标平台(Android,iOS,UWP)。
当我右键单击类库项目并单击 Pack 命令时,生成的包将按预期工作。所有平台都可以调用特定于平台的声明。
问题:
简单,[右键单击csproj文件]→Pack后面有哪些命令?我想尝试手动运行这些命令以了解发生了什么...
信息:
-
我计算机上的
- msbuild版本:16.7.0.37604(位于
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
上)
GitHub CI上的 - msbuild版本:16.7.0 + b89cb5fde GitHub CI上的
- dotnet版本:3.1.301
解决方法
显然,MSBuild CLI中存在一个错误。
使用以下命令时:
tasks
产生的nupkg可以安装在Xamarin.Forms应用程序的每个项目中,并且可以调用特定于平台的代码。
但是,在指定了msbuild /t:Pack /p:Configuration=Debug Library/Company.Xamarin.Alert/Company.Xamarin.Alert.csproj
参数的情况下运行同一命令时:
p:OutputPath
结果msbuild /t:Pack /p:Configuration=Debug /p:OutputPath=../.. Library/Company.Xamarin.Alert/Company.Xamarin.Alert.csproj
仅包含UWP的定义。
我为此here提交了一个错误。
我最终的工作流程如下:
nupkg