Skip to content

add ability to package all of powershell core as a NuGet Package#4363

Merged
daxian-dbw merged 20 commits intoPowerShell:masterfrom
TravisEz13:AddNugetPackagingV2
Aug 1, 2017
Merged

add ability to package all of powershell core as a NuGet Package#4363
daxian-dbw merged 20 commits intoPowerShell:masterfrom
TravisEz13:AddNugetPackagingV2

Conversation

@TravisEz13
Copy link
Copy Markdown
Member

@TravisEz13 TravisEz13 commented Jul 27, 2017

Example usage

function Update-Powershell 
{
    param([string]$target='~/powershell')

    if(!(Get-PackageSource -Name powershell -ErrorAction SilentlyContinue))
    {
        Register-PackageSource -Name powershell -Location https://powershell.myget.org/F/powershell-core-daily  -ProviderName nuget -Trusted
    }

    if($ismacos){
        $package = 'powershell-osx.10.12-x64'
    }
    elseif($iswindows)
    {
        $package = 'powershell-win-x64-win7-x64'
    }
    elseif($islinux)
    {
        $package = 'powershell-linux-x64'
    }

    if(!(test-path $target))
    {
        md $target
    }

    find-package -Source powershell -AllowPrereleaseVersions -name $package |Install-Package -Destination $target -ExcludeVersion
    if(!$isWindows){
        chmod a+x "$target/$package/content/pwsh"
    }
    &"$target/$package/content/pwsh"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe change the name to 'content'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems we never use "CLI". Maybe <title>PowerShell Core $runtime$</title>.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or just PowerShell for $runtime$ :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Update to PowerShell Core

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We have #4352 under review - should we use "Microsoft" in community project?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

remove microsoft

build.psm1 Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Better use the verb Sync, as Get- usually indicates result(s) will be returned while Sync is an action.

build.psm1 Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about return (git tag --list --sort=-v:refname | Select-Object -First 1)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Your proposed implementation depends on version sorting.
The code I wrote gets the latest commit which is a tag, then gets the name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

discussed offline and git describe --abbrev=0 does what you intended.

build.psm1 Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo: in -> if

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed

build.psm1 Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

git describe --dirty causes git to crash on my machine. No idea why is that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

perhaps it could not find the git-dir. I'll update all the commands to specify it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or just PowerShell for $runtime$ :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: there are trailing spaces in this line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

#resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: same here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

#resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This description needs to be updated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

#resloved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PowerShell CLI

Maybe just PowerShell

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed to PowerShell Core

build.psm1 Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we continue to use git describe to get the commit id. It should work as long as we merge the release branch.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated

@TravisEz13 TravisEz13 force-pushed the AddNugetPackagingV2 branch from 3ab8281 to 4bf60fd Compare July 28, 2017 19:16
@TravisEz13 TravisEz13 force-pushed the AddNugetPackagingV2 branch from 4bf60fd to ac6c62a Compare July 28, 2017 20:20
}
elseif(!$upstreamRemote)
{
Write-Error "Please add a remote to PowerShell\PowerShell. Example: git remote add $upstreamRemoteDefaultName $PowerShellRemoteUrl" -ErrorAction Stop
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we continue to execute the script after the error?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You should not continue executing the script unless you have a remote to PowerShell as the error indicates. The script has always assumed you can fetch the tags. This is just adding a verification.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should only occur when someone manually runs the function and it cannot complete the action. So, returning an error and stopping is the correct thing to do.

-->
<PropertyGroup>
<AssemblyName>NotUsed</AssemblyName>
<Description>PowerShell Core nuget packag with .NET CLI host including everything needed to run it.</Description>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Typo - "packag".

Copy link
Copy Markdown
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

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

LGTM except for a minor comment.

$dotnetCLIRequiredVersion = "2.0.0-preview2-006502"
$tagsUpToDate = $false

function Sync-PSTags
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please add a comment to explain why we need to run Sync-PSTags before getting the version (tag) and commit ID? It will help people to understand.

@daxian-dbw daxian-dbw merged commit e829053 into PowerShell:master Aug 1, 2017
@TravisEz13 TravisEz13 deleted the AddNugetPackagingV2 branch August 4, 2017 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants