Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish a StoreBroker NuGet package. #30

Merged
merged 1 commit into from
Apr 19, 2017
Merged

Publish a StoreBroker NuGet package. #30

merged 1 commit into from
Apr 19, 2017

Conversation

danbelcher-MSFT
Copy link
Contributor

@danbelcher-MSFT danbelcher-MSFT commented Mar 7, 2017

This change adds support for publishing a StoreBroker NuGet package. The CONTRIBUTING.md is updated to reference the internal repo as the location
for documentation describing the packaging/publishing process.

StoreBroker.nuspec is added to the root directory and describes the content for the .nupkg. The author of the package is Microsoft and the package will be co-owned by the 'microsoft' and 'nugetstorebrokerteam' NuGet accounts.

The .nupkg will contain the entirety of the StoreBroker subfolder (the files constituting the module), both of the Extensions\ConvertFrom-* scripts, and the XSD files from the PDP folder (for validating PDP XML schema).

Resolves #1 : Create and publish NuGet package

@msftclas
Copy link

msftclas commented Mar 7, 2017

@danbelcher-MSFT,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

Copy link
Member

@HowardWolosky HowardWolosky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start

CONTRIBUTING.md Outdated
@@ -70,6 +70,9 @@ As StoreBroker is a production dependency for Microsoft, we have a couple workfl
the members above.
- Releases are performed by a member above so that we can ensure Microsoft internal processes
remain up to date with the latest and that there are no regressions.
- Although this repo contains documentation for publishing the StoreBroker NuGet package, that
workflow is not able to be completed by employees outside Microsoft. For more information,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"by employees outside Microsoft" -> "by users outside Microsoft"

# Copyright (C) Microsoft Corporation. All rights reserved.

<#
.SYNOPSIS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate the .SYNOPSIS as .DESCRIPTION, but then also add:

    The Git-repo for the StoreBroker module can be found here: https://aka.ms/StoreBroker

$manifest = Invoke-Expression -Command $manifestContent

# Create the package using the module version
& nuget pack $NuSpecPath -Properties version=$($manifest.ModuleVersion) -OutputDirectory $OutPath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like nuget is available in the default path -- also possibly not even installed by default. May want to consider dot sourcing Helpers.ps1 and NugetTools.ps1 so that you can access Get-NugetExe to ensure you have access to it without needing to bother the user...


This document describes the process for releasing an updated version of the StoreBroker NuGet package.
It assumes you are a member of the `[email protected]` distribution list and, therefore,
is restricted to Microsoft internal employees.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the word "internal"

3. At the sign-in page, click `Lost your Password`.
4. Send the password reset email to `[email protected]`.
5. Open the email (check your spam folder if you do not see it) and follow the reset link.
6. The new password will be a GUID. From a PowerShell console, run:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The new password will be a GUID." --> "Use a GUID for the new password."

5. Open the email (check your spam folder if you do not see it) and follow the reset link.
6. The new password will be a GUID. From a PowerShell console, run:

[Guid]::NewGuid()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could possibly suggest this instead:

(Get-Culture).TextInfo.ToTitleCase([Guid]::NewGuid())

downloads nuget.exe from http://nuget.org to a new local temporary directory
and returns the path to the local copy.

The Git repo for this module can be found here: http://aka.ms/StoreBroker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update link to https

Write-Host "]."

$out = @()
$out += "To prevent this download in the future, download NuGet.exe from NuGet.org and"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of saying "download NuGet.exe from NuGet.org and make sure it is accessible from the system PATH", why not just say "copy $nugetExePath to a directory accessible from the system PATH"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I clean up the temporary directory when the script finishes, in order to not clutter the computer, so the downloaded executable no longer exists. Do you prefer that I leave the temp folder and print this message you suggested?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, right. I wrote that comment before I saw your other code later. Leave what you have as-is.

$manifest = Invoke-Expression -Command $manifestContent

# Create the package using the module version
& (Get-NugetExe) pack $NuSpecPath -Properties version=$($manifest.ModuleVersion) -OutputDirectory $OutPath -NoPackageAnalysis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if $OutPath is specified as a relative path, will this still work? Does the path need to be resolved first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, still works with a relative path

$manifest = Invoke-Expression -Command $manifestContent

# Create the package using the module version
& (Get-NugetExe) pack $NuSpecPath -Properties version=$($manifest.ModuleVersion) -OutputDirectory $OutPath -NoPackageAnalysis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we want package analysis?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package analysis dumps a bunch of warnings, none of which are useful, and recommends an action that we don't want. Every .ps1 gets a 3-line warning:
WARNING: Issue: PowerShell file outside tools folder.
WARNING: Description: The script file 'StoreBrokerNuGet\StoreBroker\NugetTools.ps1' is outside the 'tools' folder and hence will not be executed during installation of this package.
WARNING: Solution: Move it into the 'tools' folder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm...tried doing some searching to see if there's something that can be done to mark those as ignorable and still get the analysis, but came up short. It's probably worth a comment there to indicate that analysis is skipped because it gives false-positive warnings since we're not putting our PowerShell scripts into the Tools directory.

}
finally
{
if (($null -ne $script:tempFolderPath) -and (Test-Path -PathType Container -Path $script:tempFolderPath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment that this is being set in Get-NugetExe, and then add a .NOTES section to Get-NugetExe that a side-effect of running that script is the potential setting of that script variable. That script variable should also be set to $null by default for clarity.

@@ -30,7 +30,7 @@ function Get-NugetExe
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$script:nugetExePath = Join-Path $(New-TemporaryDirectory) "nuget.exe"

Write-Log "Downlading $sourceNugetExe to $script:nugetExePath" -Level Verbose
Write-Log "Downloading $sourceNugetExe to $script:nugetExePath" -Level Verbose
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Since you are changing a file in the module though, increment the patch number in the module manifest.

$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$nugetExePath = Join-Path -Path $script:tempFolderPath -ChildPath "nuget.exe"

Write-Host "Downloading [" -NoNewline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit unnecessary. I tried it and didn't get a lot of value out of it, visually.
Just stick with a regular, old-fashioned single line Write-Host without bothering with ForegroundColor. It'll make the code easier t read that way too. Skip the coloring on the next one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -6,7 +6,7 @@
CompanyName = 'Microsoft Corporation'
Copyright = 'Copyright (C) Microsoft Corporation. All rights reserved.'

ModuleVersion = '1.4.5'
ModuleVersion = '1.4.6'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update ModuleVersion appropriately when it's time to check in

# New-NuGetPackage.ps1 body
try
{
if (-not $IgnoreUnsigned.IsPresent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I wasn't aware of the IsPresent property on switches. I think that could be useful in the future.

Every time you need to access the account you should follow the password reset process.
7. Sign in using the new password.

### Create an API Key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you be updating this with publishing steps as well?


This document describes the process for releasing an updated version of the StoreBroker NuGet package.

### Signing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should note that the signed files should be pushed into master as well.

Copy link
Member

@HowardWolosky HowardWolosky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Go ahead and fix these remaining changes, do a final rebase/squash, and then bring it in to Master.

Thanks!

CONTRIBUTING.md Outdated
@@ -301,6 +301,9 @@ Where:
* `<minor>` - If this is a feature update, increment by one and be sure to reset `<patch>` to 0.
* `<patch>` - If this is a bug fix, leave `<minor>` alone and increment this by one.

When new code changes are checked in to the repo, a new NuGet package must be published. This process is documented in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be published by Microsoft.

CONTRIBUTING.md Outdated
@@ -301,6 +301,9 @@ Where:
* `<minor>` - If this is a feature update, increment by one and be sure to reset `<patch>` to 0.
* `<patch>` - If this is a bug fix, leave `<minor>` alone and increment this by one.

When new code changes are checked in to the repo, a new NuGet package must be published. This process is documented in
the internal repo. Refer to the CONTRIBUTING.md in that repo for more information on creating a signed NuGet package.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documented in Microsoft's internal StoreBroker repo.

</metadata>
<files>
<file src="StoreBroker\" target="StoreBroker\"/>
<file src="Extensions\ConvertFrom-ExistingSubmission.ps1" target="Extensions\"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious ... why call out these individual files here as opposed to just having all extensions go to Extensions the way that you do for StoreBroker\?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this was because an earlier iteration introduced a script here that we didn't want packaged. That script is moved to the internal repo so it will be fine to just have the Extensions folder. Good feedback.

@@ -6,7 +6,7 @@
CompanyName = 'Microsoft Corporation'
Copyright = 'Copyright (C) Microsoft Corporation. All rights reserved.'

ModuleVersion = '1.6.1'
ModuleVersion = '1.7.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to update this again. Just update the patch version though (so 1.7.1).

This change adds support for publishing a StoreBroker NuGet package. The CONTRIBUTING.md is updated to reference the internal repo as the location
for documentation describing the packaging/publishing process.

StoreBroker.nuspec is added to the root directory and describes the content for the .nupkg. The author of the package is Microsoft and the package will be co-owned by the 'microsoft' and 'nugetstorebrokerteam' NuGet accounts.

The .nupkg will contain the entirety of the StoreBroker subfolder (the files constituting the module), both of the Extensions\ConvertFrom-* scripts, and the XSD files from the PDP folder (for validating PDP XML schema).
@danbelcher-MSFT danbelcher-MSFT merged commit 3ad0efa into microsoft:master Apr 19, 2017
@danbelcher-MSFT danbelcher-MSFT deleted the forked/NuGetPackaging branch April 19, 2017 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants