forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemUtilities.NuGet.cs
More file actions
29 lines (24 loc) · 879 Bytes
/
ItemUtilities.NuGet.cs
File metadata and controls
29 lines (24 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable
using Microsoft.Build.Framework;
using NuGet.Packaging.Core;
using NuGet.Versioning;
namespace Microsoft.NET.Build.Tasks
{
internal static partial class ItemUtilities
{
public static PackageIdentity GetPackageIdentity(ITaskItem item)
{
string packageName = item.GetMetadata(MetadataKeys.NuGetPackageId);
string packageVersion = item.GetMetadata(MetadataKeys.NuGetPackageVersion);
if (string.IsNullOrEmpty(packageName) || string.IsNullOrEmpty(packageVersion))
{
return null;
}
return new PackageIdentity(
packageName,
NuGetVersion.Parse(packageVersion));
}
}
}