-
Notifications
You must be signed in to change notification settings - Fork 513
[PSCore Align] Adopt build.ps1 build concept #1127
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
Comments
We should discuss what is actually required here. |
I've just been trying to build using vscode-powershell.build.ps1 and got a load of errors ; because I actually just ran the script. So I'm very interested in improvements to the build. Does this change mean removing the dependency on InvokeBuild? build.psm1 (powershell/powershell) exports the following methods.
Which of these constitutes an "entrypoint" that should be implemented? None of these look like standard/obvious commands to call; as I discovered when I wasn't able to figure out how to build PSCore without reading the docs/appveyor.yml. I feel the following points ought to be considered:
|
Since msbuild is already being used in most projects, why not standardise on that? vscode-powershell.proj This defines the targets and doesn't need to be more than a wrapper around powershell scripts. |
* Possible implementation for PowerShell#1127 * Tested both with and without EditorServices * Tested with MSBuild 15.3 Usage: PS> ./build.ps1 Known Issues * Had to fix TSC compile error in src/features/DebugSession.ts * BinaryLogger switch requires ProjectImports=None to avoid: Error: EBUSY: resource busy or locked, open 'vscode-powershell\msbuild.ProjectImports.zip' during package * Not Tested/Updated AppVeyor
@tylerl0706 While I agree that consistency is nice PowerShell Core might not be the best "baseline" for every other PowerShell project. It is quite unique and quite a large build. It seems to me we have this "grouping" of PowerShell projects:
So I don't think it makes sense to try to apply the same "custom" build system to other, much simpler to build projects. OTOH it might be nice to perhaps have a common way to start the build no matter what tool is used to build the project. Maybe that could be BTW the latest version of psake now automatically recognizes a file called @MartinSGill |
@rkeithhill While using VSCode is nice and hardly an outlandish suggestion given that it's a vscode extension, I've always taken the view that a build system that cannot give you the most common build scenario with a single command is incomplete; be that command "maven", "msbuild", "gradle", Invoke-Build or whatever else. I also feel that easy discovery is important. Powershell made this deliberate choice with the cmdlet naming convention and standardised verbs. The commands might get a bit long winded at times, but this type of design decision is what attracted me to powershell in the first place. In many ways first impressions count, and the first impression anyone who thinks of contributing code to a project has is how easily they can get it to build. Powershell doesn't really have a recognisable build system yet, so simply seeing a *.csproj or *.pom file like you would in a C# or Java project to identify build system isn't an option.
I think the jury is still out on the preferred build system for powershell related projects, nothing seems to have established itself as the defacto standard yet. Whatever the various powershell projects align on will have a big part in establishing such a defacto standard. |
@MartinSGill I agree with just about everything you're saying. Where I work - doing cross-plat C++ development - we have settled upon using We have quite a bit of stuff that needs to be installed & configured for dev/build machines: app installs, PS module installs, Conan, NPM & Artifactory config. I've started to implement that in build.ps1 via the switch I could see VSCode having a #requires -Modules InvokeBuild
Invoke-Build Restore
Invoke-Build Build # or maybe BuildAll For an example of this see: https://github.com/PowerShell/Plaster/blob/master/build.ps1 While you're there, check out: At one point, I had this idea that PowerShell needs a project system like the C# project system - where NOBODY worries about writing custom MSBuild targets files to embed resources or strong name or these days - emit a NuGet pkg. You simply provide the correct properties for the MSBuild targets file for C#. Personally I still like this idea for PowerShell. I can see an equivalent "targets" file for PowerShell modules that can handle various phases (some optional) such as: Clean, CompileSources (C#), GenerateHelp (platyPS), CopyArtifactsToOutDir (signing here doesn't generate Git changes), Analyze (PSSA), RunTests (Pester), SignFiles, GenerateModuleCatalog. And as a manual step - PublishModule. It is interesting to see various build tools trying to replicate MSBuild but with syntax specific for that language e.g. rake, psake, cake, InvokeBuild, etc. It really makes me wish MSBuild had a way to allow for DSLs to use it. Short of that, I wonder if you could create a PowerShell friendly syntax that you could then render to a temp MSBuild file (kind of like MSBuild does for SLN files) and then use MSBuild to build it? Hmm.... |
You can make Invoke-Build scripts directly invokable easily Project.build.ps1 param(
[Parameter(Position=0)]
$Tasks,
#... other script parameters
)
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters
return
}
# The usual build script stuff
task ... See the full topic Tasks/Direct. And you can extend this idea in order to add automatic bootstrapping to such a script. As a result, a user may just clone a project and run |
As far as this project now uses Invoke-Build, let me suggest a tweak. The project appveyor.yml fixes IB version to 3.2.1, quite old. Please use the latest 4.2.0 (nothing breaking for the project script). You will get colored Invoke-Build output in AppVeyor and some improved error logging, also done for AppVeyor. See PSReadLine AppVeyor log and its log with an error. |
Hey everyone - so I want to first be absolutely clear here, I had no intention of removing InvokeBuild from the build of vscode-powershell or pses. The reason behind this issue is because @SteveL-MSFT is now the lead of this project and pses (and I'm a dev on these) and since he also owns PSCore, we wanted to try to align the projects together in order to have a consistent build experience so that anyone can jump on to these projects and run the same commands to build/clean/bootstrap/etc. Now, about your comments so far, I really love the brainstorming going on here. I like @rkeithhill's example
and think that @nightroman's automatic bootstrapping is something we should investigate. One thing I'd like to achieve in this issue is that those that are use to the existing build process for vscode-powershell and pses should not have to change their ways just because we want to align with PSCore. Keith's example is a perfect example of this as folks could call the |
Note to self: don't open a vague issue and then go on holiday 😅 |
No worries. It's been a good discussion. |
Agreed! I'd like to hear @SteveL-MSFT's thoughts when he gets back from vacation. |
Looking forward to seeing where this goes. |
I think there's been some great discussion here. My objective is to simply have consistency across PowerShell Open Source projects so that contributors (including my team members) don't have to learn a different system for each repo. Minimally for the repos I own, but ideally we can set a pattern that any PowerShell project should adopt. I'm most familiar with what we've done with PSCore6 and agree that it's a bit unique, but I think conceptually, a new contributor should be able to:
However, there's also some logistical work that needs to be done to make sure all of the Microsoft repos are in Compliance. For example, before we sign binaries/packages with Microsoft's private key, we need to ensure that it was built on a secure system at Microsoft (AppVeyor/Travis builds aren't sufficient for release). So with multiple projects in multiple repos, it's better to have similar ways to build across our repos to make it easier to on-board to our internal compliance tools rather than incurring onboarding costs for each repo as they have distinct ways of doing builds/releases. I'm fine with having 2 similar but different ways of doing things for small projects vs big projects if it improves engineering efficiency and keeps things simpler. |
Cool. I propose that the vast majority of simpler, module-based PowerShell projects use a more-or-less standardized repo root level
And be committed to Git with (so you can fire it off from Bash or another shell):
The script when run without any parameters would ideally "build" the module - whatever that means. It could have an optional Whether that script chains down to a tool like psake or InvokeBuild (or MSBuild) shouldn't matter as much for a person just starting dev work on a project. Anyway, just a few thoughts to continue the discussion. :-) |
The standardization on I think it's fine for |
Oops, copied that from an old repo. Yeah, should be |
Some thoughts on build.ps1 with InvokeBuild or psake and bootstrapping,
|
Build tools may be installed to and imported from a local temporary directory (say, packages). This way does not pollute standard module directories. |
Using Invoke-Build directly seems far more flexible to me. |
I guess what I'm shooting for is more of a PowerShell community standard and as good as |
This was exactly a reason why InvokeBuild did not choose this name for its default script. |
Great discussion everyone! Compiling our thoughts... and copy and pasting a bunch, here's what I have: Module-based PowerShell projects should* use a repo root level Tasks
ContentsWhat the However, the file should have a shebang:
And be committed to Git with (so you can fire it off from Bash or another shell):
|
vscode-powershell & PowerShellEditorServices can follow this. Their "Build" would run Thoughts? |
Sounds good. We can stage this so that |
If a project and its build.ps1 use InvokeBuild then you can continue to call As far as I understand build.ps1 will be responsible for bootstrapping. The approach of using helper scripts FAKE based projects provide Another popular build engine Cake provides build.ps1 in addition to the |
Looks good to me. I've already been using a build.ps1 wrapper for my c# / npm projects, so this suits me really well. We could add a -test switch to build.ps1, and indeed if you also add a publish/package option then the build script would do 90% of everything most developers will ever need to do, and all without them having to gain any underlying knowledge of the build/test toolchain. Another good aspect of this is that you'll get powershell completion for the primary build tasks, even if the underlying tool(s) do not have such support. I'd add a requirement/specification that build.ps1 should only be a facade and not itself contain any build logic, to ensure build logic isn't spread around all over the place. Longer term: keeping it simple should make it possible to easily generate these build files as part of Plaster/Yeoman templates, or create a library resource of them for people to just quickly select the correct one for their preferred build system. |
Here's the build.ps1 PR for PowerShellEditorServices: |
And here's the PR for vscode-powershell: |
Simplify build script to be consistent with PowerShell/vscode-powershell#1127 (comment) Change location of assemblies in the case of FullClr/PowerShell 5 into it's own directory (like PSv3 and coreclr)
PowerShell Core has this concept of a
build.psm1
file that contains a bunch of functions for building and testing PSCore: https://github.com/PowerShell/PowerShell/blob/master/build.psm1We should align with those processes so that it's consistent across PowerShell repos.
We can still continue to use InvokeBuild, but we can wrap the
Invoke-Build *
with the same entrypoints that PSCore has.The text was updated successfully, but these errors were encountered: