Add NUKE build aligned with pipenv build products#3129
Add NUKE build aligned with pipenv build products#3129OnePowerUser88 wants to merge 5 commits intopyrevitlabs:developfrom
Conversation
|
Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔 |
|
Important note: |
|
Hi @OnePowerUser88 , thanks for the contribution. The goal of using nuke is to completely remove the pipenv environment, also in the CI/CD. There are other commands in the Do you think you can address these as well, or do you believe it should be done on a separate PR? Also, can you please omit the not strictly needed files? This move to nuke should't change the DLLs. |
|
Will look into it! Just to make sure: |
- build/: Build.cs, README, csproj, nuget.config - build.ps1: bootstrap for .NET NUKE runner - .gitignore: .nuke/, build/bin/ No DLL or source changes. Remaining pyrevit.py commands to be ported in follow-up for full pipenv removal. Co-authored-by: Cursor <cursoragent@cursor.com>
167995c to
1226691
Compare
I'm not able to find a solution to build without editing mongo.go and ScriptConsole.cs without it failing. Anyone have any input? |
What is the error |
…dTelem in full build, README
Summary of source file changes (this branch)This comment describes the source code changes introduced alongside the NUKE build. These are product improvements and bug fixes that apply whether you use pipenv or NUKE. Verified in Revit 2024 and 2026 after build. 1.
|
| File | What changed | Why |
|---|---|---|
| ScriptConsole.cs | Theme loaded via TryAddThemeResource (canonical + lowercase fallback); theme added before Controls.xaml |
Fix “Cannot locate resource 'styles/themes/light.blue.xaml'” in Revit 2024/2026 |
| mongo.go | v2 driver imports; mongo.Connect(opts); mongoDatabaseFromURI instead of connstring; error handling and defers |
Telemetry server Go build was broken; v2 API and no deprecated connstring |
| go.mod / go.sum | go.sum updated via go mod tidy |
Reproducible build with v2 driver |
| Build.cs | BuildProducts depends on BuildTelem again | Full build produces telemetry exe like pipenv |
| build/README.md | “Source code used by this build” section | Clarify that changes are product improvements, not Nuke workarounds |
There was a problem hiding this comment.
Pull request overview
This PR introduces a NUKE-based build pipeline intended to produce the same build artifacts as the existing pipenv run pyrevit build products, enabling building the repository without Python/pipenv while keeping the pipenv workflow available.
Changes:
- Added a NUKE build project (
build/) plus a rootbuild.ps1bootstrap script to build C# and Go products and perform release-related versioning tasks. - Updated the telemetry server MongoDB persistence code to use the
go.mongodb.org/mongo-driver/v2driver and adjusted connection-string database name parsing. - Adjusted ScriptConsole WPF resource loading to add a theme dictionary first and fall back to a lowercase theme URI.
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| dev/pyRevitTelemetryServer/persistence/mongo.go | Switches MongoDB integration to mongo-driver v2 and adds URI DB-name parsing helper. |
| dev/pyRevitTelemetryServer/go.mod | Updates Go module dependency list (removes/adjusts indirect deps). |
| dev/pyRevitTelemetryServer/go.sum | Updates dependency checksums in line with the Go module changes. |
| dev/pyRevitLabs.PyRevit.Runtime/ScriptConsole.cs | Adds theme resource loading fallback and changes merge order to prevent missing-resource errors. |
| build/nuget.config | Adds NuGet configuration affecting signature validation behavior during restores. |
| build/build.csproj | Adds a net8.0 NUKE build project referencing Nuke.Common. |
| build/README.md | Documents NUKE build usage, targets, outputs, and troubleshooting. |
| build/Build.cs | Implements NUKE targets for building deps/labs/loaders/runtime, deploying libs, building Go tools, and some release automation. |
| build.ps1 | Adds a root PowerShell bootstrapper to compile and run the NUKE build. |
| .gitignore | Ignores NUKE’s .nuke/ and build runner output under build/bin/. |
| ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
| defer cancel() | ||
|
|
||
| logger.Debug("opening mongodb session") | ||
| client, err := mongo.Connect(ctx, options.Client().ApplyURI(w.Config.ConnString)) | ||
|
|
||
| client, err := mongo.Connect(options.Client().ApplyURI(w.Config.ConnString)) | ||
| if err != nil { | ||
| return "" | ||
| } | ||
| defer func() { | ||
| if err = client.Disconnect(ctx); err != nil { | ||
| panic(err) | ||
| if dErr := client.Disconnect(ctx); dErr != nil { | ||
| panic(dErr) |
There was a problem hiding this comment.
In GetVersion(), the deferred Disconnect uses the ctx variable, but ctx is reassigned later for Ping/RunCommand. Because the deferred closure captures ctx by reference, Disconnect will run with the second (2s) context (likely already canceled), which can cause Disconnect to fail and the code to panic. Use a dedicated context variable for Disconnect (or capture the original ctx in a local var inside the defer) and use separate contexts for Ping/RunCommand.
build/nuget.config
Outdated
| <config> | ||
| <!-- Skip NuGet signature verification if it fails (e.g. proxy/corporate SSL) --> | ||
| <add key="signatureValidationMode" value="accept" /> | ||
| </config> |
There was a problem hiding this comment.
This repo-level NuGet config disables package signature verification (signatureValidationMode=accept). That weakens supply-chain protections for everyone building the repo, not just users behind problematic proxies. Prefer removing this from source control and documenting a per-user workaround (e.g., local NuGet.Config), or limit the relaxation to a narrowly-scoped restore step that’s explicitly opt-in.
| <config> | |
| <!-- Skip NuGet signature verification if it fails (e.g. proxy/corporate SSL) --> | |
| <add key="signatureValidationMode" value="accept" /> | |
| </config> | |
| <!-- | |
| Note: Do not disable NuGet package signature verification at the repo level. | |
| If you need to relax signature checks (e.g. due to corporate SSL interception), | |
| configure that in a user-specific NuGet.Config outside of source control. | |
| --> |
| var outputExe = BinPath / "pyrevit-telemetryserver.exe"; | ||
| BinPath.CreateDirectory(); | ||
| RunProcess("go", "get ./...", (string)telemPath, captureOutput: true, unsetProxy: true); | ||
| RunProcess("go", $"build -o \"{outputExe}\" .", (string)telemPath, captureOutput: true, unsetProxy: true); |
There was a problem hiding this comment.
Using go get ./... as part of the build can modify go.mod/go.sum (and potentially pull newer dependency versions), making builds non-reproducible and leaving a dirty working tree. Prefer go mod download (or just go build, which will fetch modules as needed) so the build doesn’t change module files.
| var outputExe = BinPath / "pyrevit-autocomplete.exe"; | ||
| BinPath.CreateDirectory(); | ||
| RunProcess("go", "get ./...", (string)autocmpPath, captureOutput: true, unsetProxy: true); | ||
| RunProcess("go", $"build -o \"{outputExe}\" .", (string)autocmpPath, captureOutput: true, unsetProxy: true); | ||
| } |
There was a problem hiding this comment.
Same issue as BuildTelem: running go get ./... during BuildAutocmp can update go.mod/go.sum and fetch newer dependency versions. Prefer go mod download / go build to keep the build reproducible and avoid modifying the repo during a build.
build/Build.cs
Outdated
| var year = DateTime.Now.Year; | ||
| if (DateTime.Now.Month == 12) year++; |
There was a problem hiding this comment.
SetYear bumps the year for the entire month of December (if (DateTime.Now.Month == 12) year++;). The existing pipenv implementation only bumps when within ~30 days of Jan 1, so this will update copyright too early in most of December. Consider porting the same threshold logic from dev/_props.py to keep behavior consistent.
| var year = DateTime.Now.Year; | |
| if (DateTime.Now.Month == 12) year++; | |
| var now = DateTime.Now; | |
| var year = now.Year; | |
| var nextJan1 = new DateTime(year + 1, 1, 1); | |
| var threshold = nextJan1.AddDays(-30); | |
| if (now >= threshold) | |
| year++; |
…ng config guards, remove nuget.config Made-with: Cursor
|
I’ve pushed a follow‑up commit to address the review feedback and harden a couple of edge cases: Mongo telemetry (
|
Add NUKE build (replace pipenv for build products)
Description
Disclamer the PR is largely created by Cursor, someone familiar with the build process needs to review this PR!
The main reason I created this PR is because I had problems with pipenv and @jmcouffin and @sanzoghenzo mentioned that NUKE was considered as an option.
This PR adds a NUKE-based build so the repo can be built without Python or pipenv. Running
.\build.ps1 BuildProductsfrom the folder that containsbuild/produces the same artifacts aspipenv run pyrevit build products. Pipenv is not removed or changed — developers can use eitherpipenv run pyrevit build productsor.\build.ps1 BuildProducts.Included:
Build.cs,build.ps1,README.md,build.csproj,nuget.config. Targets: BuildDeps → BuildLabs → BuildLoaders → BuildRuntime → DeployLibsToEngines → BuildTelem → BuildAutocmp, plus Clean and Check.RunProcesswith captured MSBuild output on failure, and/m:1so Deploy targets don’t race; Clean then BuildProducts succeeds on first run.pyrevit-autocomplete.exefrom the checked-in Go source (regenerate viapipenv run pyrevit build autocmpwhen CLI usage changes)..nuke/,build/bin/(NUKE runner output; not committed).Directory.Build.targetsCopy retries, telemetrymongo.goupdates.CI can be switched to NUKE later if desired.
Checklist
Before submitting your pull request, ensure the following requirements are met:
.\build.ps1 Checkpasses (dotnet and go on PATH)..\build.ps1 Cleanthen.\build.ps1 BuildProductssucceeds.Related Issues
Additional Notes
build/, run.\build.ps1 Checkthen.\build.ps1 BuildProducts(requires .NET SDK and Go). No pipenv needed.