Skip to content

Commit 9acb9c3

Browse files
committed
Fix Director tool pack fallback
1 parent ec55e21 commit 9acb9c3

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

build/Build.BuildAndDeployTargets.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,40 @@ private string ExecuteDotnetToolPipeline(
221221
File.Delete(nupkgPath);
222222
}
223223

224+
var supportsDotNetToolPack = propertyGroups
225+
.SelectMany(group => group.Elements())
226+
.Any(element =>
227+
string.Equals(element.Name.LocalName, "PackAsTool", StringComparison.OrdinalIgnoreCase) &&
228+
bool.TryParse(element.Value.Trim(), out var enabled) &&
229+
enabled);
230+
224231
if (CommandExists("nuget"))
225232
{
226233
InvokeProcess("nuget", new List<string> { "pack", nuspecPath, "-OutputDirectory", outputDirectory, "-NoPackageAnalysis" }, RepoRootPath, true);
227234
}
235+
else if (supportsDotNetToolPack)
236+
{
237+
InvokeDotNet(
238+
new List<string>
239+
{
240+
"pack",
241+
projectPath,
242+
"-c",
243+
Configuration,
244+
"-o",
245+
outputDirectory,
246+
"/p:PackageVersion=" + version.SemVer,
247+
"/p:Version=" + version.SemVer,
248+
"/p:AssemblyVersion=" + $"{version.Major}.{version.Minor}.{version.Patch}",
249+
"/p:FileVersion=" + $"{version.Major}.{version.Minor}.{version.Patch}",
250+
"/p:InformationalVersion=" + version.SemVer
251+
},
252+
RepoRootPath,
253+
true);
254+
}
228255
else
229256
{
230-
InvokeDotNet(new List<string> { "nuget", "pack", nuspecPath, "-OutputDirectory", outputDirectory, "-NoPackageAnalysis" }, RepoRootPath, true);
257+
throw new InvalidOperationException($"nuget.exe was not found in PATH and {Path.GetFileName(projectPath)} does not declare PackAsTool for dotnet pack fallback.");
231258
}
232259

233260
if (installAfterPack)

0 commit comments

Comments
 (0)