@@ -39,7 +39,7 @@ Properties {
3939 $ChocolateySpecPath = Join-Path $ChocolateyDir " TfsCmdlets.nuspec"
4040
4141 # Wix packaging
42- $WixVersion = " $Version "
42+ $FourPartVersion = " $ ( $VersionMetadata .MajorMinorPatch ) . $BuildNumber "
4343 $WixOutputPath = Join-Path $SolutionDir " Setup\bin\$Configuration "
4444
4545 # 7zip
@@ -76,9 +76,8 @@ Task CleanOutputDir {
7676Task BuildLibrary {
7777
7878 $LibSolutionPath = (Join-Path $SolutionDir ' Lib/TfsCmdletsLib.sln' )
79- $TargetDir = (Join-Path $ModuleDir ' Lib' )
8079
81- exec { msbuild $LibSolutionPath / t:Rebuild / p:Configuration= $Configuration / p:Version= $Version / p:AssemblyVersion= $Version / v:d | Write-Verbose }
80+ exec { msbuild $LibSolutionPath / t:Restore ` ;Build / p:Configuration= $Configuration / p:Version= $FourPartVersion / p:AssemblyVersion= $FourPartVersion / p:AssemblyInformationalVersion = $BuildName / v:d | Write-Verbose }
8281
8382
8483}
@@ -200,14 +199,15 @@ Updating module manifest file $ModuleManifestPath with the following content:
200199 -NestedModules @($ ( ($nestedModuleList | ForEach-Object { " '$_ '" }) -join ' ,' ) )
201200 -FileList @($ ( ($fileList | ForEach-Object { " '$_ '" }) -join ' ,' ) )
202201 -FunctionsToExport @($ ( ($functionList | ForEach-Object { " '$_ '" }) -join ' ,' ) )
203- -ModuleVersion '$Version '
202+ -ModuleVersion '$ ( $VersionMetadata .NugetVersion ) '
204203 -CompatiblePSEditions @($ ( ($CompatiblePSEditions | ForEach-Object { " '$_ '" }) -join ' ,' ) )
205204 -PrivateData @{
206- Branch = '$BranchName '
205+ Branch = '$ ( $VersionMetadata . BranchName) '
207206 Build = '$BuildName '
208- Commit = '$Commit '
207+ Commit = '$ ( $VersionMetadata . Commit) '
209208 TfsClientVersion = '$tfsOmNugetVersion '
210- PreRelease = '$PreRelease '
209+ PreRelease = '$ ( $VersionMetadata.NugetPrereleaseTag ) '
210+ Version = '$ ( $VersionMetadata.FullSemVer ) '
211211 }
212212}
213213"@
@@ -216,14 +216,15 @@ Updating module manifest file $ModuleManifestPath with the following content:
216216 - NestedModules $nestedModuleList `
217217 - FileList $fileList `
218218 - FunctionsToExport $functionList `
219- - ModuleVersion $Version `
219+ - ModuleVersion $VersionMetadata .MajorMinorPatch `
220220 - CompatiblePSEditions $CompatiblePSEditions `
221221 - PrivateData @ {
222- Branch = $BranchName
222+ Branch = $VersionMetadata . BranchName
223223 Build = $BuildName
224- Commit = $Commit
224+ Commit = $VersionMetadata .Sha
225225 TfsClientVersion = $tfsOmNugetVersion
226- PreRelease = $PreRelease
226+ PreRelease = $VersionMetadata.NugetPrereleaseTag
227+ Version = $VersionMetadata.FullSemVer
227228 }
228229}
229230
@@ -249,7 +250,7 @@ Task DownloadTfsNugetPackage {
249250 if (-not (Test-Path " $packageDir .*" - PathType Container))
250251 {
251252 Write-Verbose " $package not found. Downloading from Nuget.org"
252- & $NugetExePath Install $package - OutputDirectory packages - Verbosity Detailed - PreRelease * > & 1 | Write-Verbose
253+ & $NugetExePath Install $package - OutputDirectory packages - Verbosity Detailed - PreRelease - PackageSaveMode nuspec ` ;nupkg * > & 1 | Write-Verbose
253254 }
254255 else
255256 {
@@ -277,21 +278,21 @@ Task PackageModule -Depends Build {
277278
278279 if (-not (Test-Path $PortableDir - PathType Container)) { New-Item $PortableDir - ItemType Directory - Force | Out-Null }
279280
280- & $7zipExePath a (Join-Path $PortableDir " TfsCmdlets-Portable-$NugetVersion .zip" ) (Join-Path $OutDir ' Module\*' ) | Write-Verbose
281+ & $7zipExePath a (Join-Path $PortableDir " TfsCmdlets-Portable-$ ( $VersionMetadata . NugetVersion) .zip" ) (Join-Path $OutDir ' Module\*' ) | Write-Verbose
281282}
282283
283284Task PackageNuget - Depends Build, GenerateNuspec {
284285
285286 Copy-Item $ModuleDir $NugetToolsDir \TfsCmdlets - Recurse - Exclude * .ps1 - Force
286287
287- $cmdLine = " $NugetExePath Pack $NugetSpecPath -OutputDirectory $NugetDir -Verbosity Detailed -NonInteractive -Version $NugetVersion "
288+ $cmdLine = " $NugetExePath Pack $NugetSpecPath -OutputDirectory $NugetDir -Verbosity Detailed -NonInteractive -Version $ ( $VersionMetadata . NugetVersion) "
288289
289290 Write-Verbose " Command line: [$cmdLine ]"
290291
291292 Invoke-Expression $cmdLine * > & 1 | Write-Verbose
292293}
293294
294- Task PackageChocolatey - Depends Build {
295+ Task PackageChocolatey - Depends PackageNuget , GenerateLicenseFile , GenerateVerificationFile {
295296
296297 if (-not (Test-Path $ChocolateyPath ))
297298 {
@@ -301,7 +302,7 @@ Task PackageChocolatey -Depends Build {
301302 Copy-Item $ModuleDir $ChocolateyToolsDir \TfsCmdlets - Recurse - Force
302303 Copy-Item $NugetSpecPath - Destination $ChocolateyDir - Force
303304
304- $cmdLine = " $ChocolateyPath Pack $ChocolateySpecPath -OutputDirectory $ChocolateyDir --Version $Version "
305+ $cmdLine = " $ChocolateyPath Pack $ChocolateySpecPath -OutputDirectory $ChocolateyDir --Version $ ( $VersionMetadata .NugetVersion ) "
305306
306307 Write-Verbose " Command line: [$cmdLine ]"
307308
@@ -347,7 +348,7 @@ Task PackageMsi -Depends Build {
347348
348349 $CandleArgs = @ (
349350 " -sw$WixSuppressedWarnings " ,
350- " -dPRODUCTVERSION=$WixVersion " ,
351+ " -dPRODUCTVERSION=$FourPartVersion " ,
351352 " -d`" PRODUCTNAME=$ModuleName - $ModuleDescription `" " ,
352353 " -d`" AUTHOR=$ModuleAuthor `" " ,
353354 " -dSourceDir=$ModuleDir \" ,
@@ -362,9 +363,9 @@ Task PackageMsi -Depends Build {
362363 " -dProjectPath=$WixProjectDir \$WixProjectFileName " ,
363364 " -dTargetDir=$WixBinDir \" ,
364365 " -dTargetExt=.msi"
365- " -dTargetFileName=$ModuleName -$NugetVersion .msi" ,
366- " -dTargetName=$ModuleName -$NugetVersion " ,
367- " -dTargetPath=$WixBinDir \$ModuleName -$NugetVersion .msi" ,
366+ " -dTargetFileName=$ModuleName -$ ( $VersionMetadata . NugetVersion) .msi" ,
367+ " -dTargetName=$ModuleName -$ ( $VersionMetadata . NugetVersion) " ,
368+ " -dTargetPath=$WixBinDir \$ModuleName -$ ( $VersionMetadata . NugetVersion) .msi" ,
368369 " -I$WixProjectDir " ,
369370 " -out" , " $WixObjDir \" ,
370371 " -arch" , " x86" ,
@@ -377,8 +378,8 @@ Task PackageMsi -Depends Build {
377378 & (Join-Path $WixToolsDir ' Candle.exe' ) $CandleArgs * > & 1 | Write-Verbose
378379
379380 $LightArgs = @ (
380- " -out" , " $WixBinDir \$ModuleName -$NugetVersion .msi" ,
381- " -pdbout" , " $WixBinDir \$ModuleName -$NugetVersion .wixpdb" ,
381+ " -out" , " $WixBinDir \$ModuleName -$ ( $VersionMetadata . NugetVersion) .msi" ,
382+ " -pdbout" , " $WixBinDir \$ModuleName -$ ( $VersionMetadata . NugetVersion) .wixpdb" ,
382383 " -sw1076" ,
383384 " -cultures:null" ,
384385 " -ext" , " $WixToolsDir \WixUtilExtension.dll" ,
@@ -399,8 +400,8 @@ Task PackageMsi -Depends Build {
399400
400401Task PackageDocs - Depends GenerateDocs {
401402
402- # Compress-Archive -Path $DocsDir -CompressionLevel Optimal -DestinationPath (Join-Path $DocsDir "TfsCmdlets-docs-$NugetVersion.zip")
403- & $7zipExePath a (Join-Path $DocsDir " TfsCmdlets-Docs-$NugetVersion .zip" ) $DocsDir | Write-Verbose
403+ # Compress-Archive -Path $DocsDir -CompressionLevel Optimal -DestinationPath (Join-Path $DocsDir "TfsCmdlets-docs-$($VersionMetadata. NugetVersion) .zip")
404+ & $7zipExePath a (Join-Path $DocsDir " TfsCmdlets-Docs-$ ( $VersionMetadata . NugetVersion) .zip" ) $DocsDir | Write-Verbose
404405}
405406
406407Task GenerateDocs - Depends Build {
@@ -494,3 +495,77 @@ Task GenerateNuspec {
494495
495496 Set-Content - Path $NugetSpecPath - Value $nuspec
496497}
498+
499+ Task GenerateLicenseFile {
500+
501+ $outLicenseFile = Join-Path $ChocolateyToolsDir ' LICENSE.txt'
502+
503+ if (-not (Test-Path $ChocolateyToolsDir - PathType Container))
504+ {
505+ New-Item $ChocolateyToolsDir - Force - ItemType Directory | Write-Verbose
506+ }
507+
508+ Copy-Item $SolutionDir \LICENSE.md $outLicenseFile - Force - Recurse
509+
510+ $specFiles = Get-ChildItem $NugetPackagesDir - Include * .nuspec - Recurse
511+
512+ foreach ($f in $specFiles )
513+ {
514+ $spec = [xml ] (Get-Content $f - Raw - Encoding UTF8)
515+ $packageUrl = " https://nuget.org/packages/$ ( $spec.package.metadata.id ) /$ ( $spec.package.metadata.version ) "
516+
517+ if ($spec.package.metadata.license )
518+ {
519+ if ($spec.package.metadata.license.type -eq ' file' )
520+ {
521+ $licenseFile = Join-Path $f.Directory $spec.package.metadata.license .' #text'
522+ $licenseText = Get-Content $licenseFile - Raw - Encoding Utf8
523+ }
524+ else
525+ {
526+ $licenseText = " Please refer to https://spdx.org/licenses/$ ( $spec.package.metadata.license.type ) .html for license information for this package."
527+ }
528+ }
529+ else
530+ {
531+ $licenseUrl = $spec.package.metadata.licenseUrl
532+ $licenseText = " Please refer to $licenseUrl for license information for this package."
533+ }
534+
535+ @"
536+ =============================
537+
538+ FROM $packageUrl
539+
540+ LICENSE
541+
542+ $licenseText
543+
544+ "@ | Add-Content - Path $outLicenseFile - Encoding Utf8
545+
546+ }
547+ }
548+
549+ Task GenerateVerificationFile {
550+
551+ $outVerifyFile = Join-Path $ChocolateyToolsDir ' VERIFICATION.txt'
552+
553+ $packageUrls = Get-ChildItem $NugetPackagesDir - Include * .nuspec - Recurse | ForEach-Object {
554+ $spec = [xml ] (Get-Content $_ - Raw - Encoding UTF8); `
555+ Write-Output " https://nuget.org/packages/$ ( $spec.package.metadata.id ) /$ ( $spec.package.metadata.version ) "
556+ }
557+
558+ @"
559+ VERIFICATION
560+ ============
561+
562+ Verification is intended to assist the Chocolatey moderators and community
563+ in verifying that this package's contents are trustworthy.
564+
565+ Binary files contained in this package can be compared against their respective NuGet source packages, listed below:
566+
567+ $ ( $packageUrls -join " `r`n " )
568+
569+ "@ | Out-File $outVerifyFile - Encoding Utf8
570+
571+ }
0 commit comments