@@ -29,6 +29,10 @@ public class GetPackOutputItemsTask : Microsoft.Build.Utilities.Task
2929 [ Required ]
3030 public string NuspecOutputPath { get ; set ; }
3131
32+ public string NuspecInputFilePath { get ; set ; }
33+
34+ public string [ ] NuspecProperties { get ; set ; }
35+
3236 public bool IncludeSymbols { get ; set ; }
3337
3438 public bool IncludeSource { get ; set ; }
@@ -43,27 +47,41 @@ public class GetPackOutputItemsTask : Microsoft.Build.Utilities.Task
4347
4448 public override bool Execute ( )
4549 {
50+ var packageId = PackageId ;
51+ var packageVersion = PackageVersion ;
52+
53+ if ( ! string . IsNullOrWhiteSpace ( NuspecInputFilePath ) )
54+ {
55+ var nuspecReader = new NuGet . Packaging . NuspecReader ( NuspecInputFilePath ) ;
56+ packageId = nuspecReader . GetId ( ) ;
57+ packageVersion = nuspecReader . GetVersion ( ) . ToNormalizedString ( ) ;
58+
59+ PackArgs packArgs = new PackArgs ( ) { Version = packageVersion } ;
60+ PackTaskLogic . SetPackArgsPropertiesFromNuspecProperties ( packArgs , MSBuildStringUtility . TrimAndExcludeNullOrEmpty ( NuspecProperties ) , NuspecInputFilePath ) ;
61+ packageVersion = packArgs . Version ;
62+ }
63+
4664 NuGetVersion version ;
47- if ( ! NuGetVersion . TryParse ( PackageVersion , out version ) )
65+ if ( ! NuGetVersion . TryParse ( packageVersion , out version ) )
4866 {
4967 throw new ArgumentException ( string . Format (
5068 CultureInfo . CurrentCulture ,
5169 Strings . InvalidPackageVersion ,
52- PackageVersion ) ) ;
70+ packageVersion ) ) ;
5371 }
5472
5573 var symbolPackageFormat = PackArgs . GetSymbolPackageFormat ( MSBuildStringUtility . TrimAndGetNullForEmpty ( SymbolPackageFormat ) ) ;
56- var nupkgFileName = PackCommandRunner . GetOutputFileName ( PackageId , version , isNupkg : true , symbols : false , symbolPackageFormat : symbolPackageFormat ) ;
57- var nuspecFileName = PackCommandRunner . GetOutputFileName ( PackageId , version , isNupkg : false , symbols : false , symbolPackageFormat : symbolPackageFormat ) ;
74+ var nupkgFileName = PackCommandRunner . GetOutputFileName ( packageId , version , isNupkg : true , symbols : false , symbolPackageFormat : symbolPackageFormat ) ;
75+ var nuspecFileName = PackCommandRunner . GetOutputFileName ( packageId , version , isNupkg : false , symbols : false , symbolPackageFormat : symbolPackageFormat ) ;
5876
5977 var outputs = new List < ITaskItem > ( ) ;
6078 outputs . Add ( new TaskItem ( Path . Combine ( PackageOutputPath , nupkgFileName ) ) ) ;
6179 outputs . Add ( new TaskItem ( Path . Combine ( NuspecOutputPath , nuspecFileName ) ) ) ;
6280
6381 if ( IncludeSource || IncludeSymbols )
6482 {
65- var nupkgSymbolsFileName = PackCommandRunner . GetOutputFileName ( PackageId , version , isNupkg : true , symbols : true , symbolPackageFormat : symbolPackageFormat ) ;
66- var nuspecSymbolsFileName = PackCommandRunner . GetOutputFileName ( PackageId , version , isNupkg : false , symbols : true , symbolPackageFormat : symbolPackageFormat ) ;
83+ var nupkgSymbolsFileName = PackCommandRunner . GetOutputFileName ( packageId , version , isNupkg : true , symbols : true , symbolPackageFormat : symbolPackageFormat ) ;
84+ var nuspecSymbolsFileName = PackCommandRunner . GetOutputFileName ( packageId , version , isNupkg : false , symbols : true , symbolPackageFormat : symbolPackageFormat ) ;
6785
6886 outputs . Add ( new TaskItem ( Path . Combine ( PackageOutputPath , nupkgSymbolsFileName ) ) ) ;
6987 outputs . Add ( new TaskItem ( Path . Combine ( NuspecOutputPath , nuspecSymbolsFileName ) ) ) ;
0 commit comments