{"id":13568986,"url":"https://github.com/br-na-pm/BuildVersion","last_synced_at":"2025-04-04T05:30:59.367Z","repository":{"id":37767084,"uuid":"475927834","full_name":"br-na-pm/BuildVersion","owner":"br-na-pm","description":"Collect git version information during a project build","archived":false,"fork":false,"pushed_at":"2024-10-30T01:45:12.000Z","size":123,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-30T03:59:41.200Z","etag":null,"topics":["automation-studio","git","machine-automation","powershell","version-control"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/br-na-pm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-30T14:56:39.000Z","updated_at":"2024-10-30T01:45:16.000Z","dependencies_parsed_at":"2023-02-08T20:46:36.384Z","dependency_job_id":"6e5d53bf-e853-453a-aa84-f224157aff85","html_url":"https://github.com/br-na-pm/BuildVersion","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/br-na-pm%2FBuildVersion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/br-na-pm%2FBuildVersion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/br-na-pm%2FBuildVersion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/br-na-pm%2FBuildVersion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/br-na-pm","download_url":"https://codeload.github.com/br-na-pm/BuildVersion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128698,"owners_count":20888232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation-studio","git","machine-automation","powershell","version-control"],"created_at":"2024-08-01T14:00:34.325Z","updated_at":"2025-04-04T05:30:59.054Z","avatar_url":"https://github.com/br-na-pm.png","language":"PowerShell","funding_links":[],"categories":["Development Tools"],"sub_categories":["Automation Studio"],"readme":"# BuildVersion\n\n[![Made for B\u0026R](https://raw.githubusercontent.com/hilch/BandR-badges/dfd5e264d7d2dd369fd37449605673f779db437d/Made-For-BrAutomation.svg)](https://www.br-automation.com)\n![GitHub License](https://img.shields.io/github/license/br-na-pm/BuildVersion)\n![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/br-na-pm/BuildVersion/total)\n[![GitHub issues](https://img.shields.io/github/issues-raw/br-na-pm/BuildVersion)](https://github.com/br-na-pm/BuildVersion/issues)\n\n[BuildVersion](https://github.com/br-na-pm/BuildVersion#readme) is a software package for [Automation Studio](https://www.br-automation.com/en/products/software/automation-software/automation-studio/) projects to transfer version information to runtime variables during each build.\n\nThe package includes a Windows-native [PowerShell](https://learn.microsoft.com/en/powershell/) script to automatically capture version information during the pre-build event.  \nThe script is intended for use with the version control system [git](https://git-scm.com/).\n\n**NOTE:** This is not an official package and is supported by the community.  BuildVersion is provided as-in under the [MIT License](https://mit-license.org/) agreement.  Source code, documentation, and issues are managed through [GitHub](https://github.com/br-na-pm/BuildVersion).\n\n![Initialize build version 2022-03-31_12 27 13](https://user-images.githubusercontent.com/33841634/161134786-7ea1422b-55c4-4f49-a427-3e261ded259d.png)\n\n## Features\n\n- :octocat: Capture git repository information\n- :arrow_down: Capture Automation Studio project and build information\n- :beginner: Use with and without git\n- :file_folder: Initialize local variable\n- :earth_americas: Initialize global variable\n- :warning: PowerShell script will not throw error in project build by default\n- :tv: [mappView widget](https://github.com/br-na-pm/BuildVersionWidget#readme) integration\n\n## Installation\n\n#### 1. Add Package to Project\n\n- [Download](https://github.com/br-na-pm/BuildVersion/releases/latest/download/BuildVersion.zip) and extract\n- Logical View -\u003e select project folder -\u003e Toolbox -\u003e Existing Package -\u003e import BuildVersion\n\n![Step 1 2022-04-10_13-37-35](https://user-images.githubusercontent.com/33841634/162637472-ddf53ad9-52b9-4f34-935c-5416d5bc9a55.gif)\n\n#### 2. Create Pre-Build Event\n\n- Configuration View -\u003e active configuration -\u003e right-click CPU object -\u003e Properties\n- Build Events -\u003e Configuration Pre-Build Step -\u003e Insert the following\n\n```powershell\nPowerShell -ExecutionPolicy ByPass -File $(WIN32_AS_PROJECT_PATH)\\Logical\\BuildVersion\\BuildVersion.ps1 -ProjectPath $(WIN32_AS_PROJECT_PATH) -StudioVersion \"$(AS_VERSION)\" -UserName \"$(AS_USER_NAME)\" -ProjectName \"$(AS_PROJECT_NAME)\" -Configuration \"$(AS_CONFIGURATION)\" -BuildMode \"$(AS_BUILD_MODE)\"\n```\n\n![Step 2 2022-04-10_13-49-32](https://user-images.githubusercontent.com/33841634/162637534-a7b174c9-fff3-4a81-9096-b1335f0e7f23.gif)\n\nIf the BuildVersion package is placed in subdirectories of Logical, the pre-build event must be updated to reflect the subdirectories.  \nFor example, if the BuildVersion package is placed in a `Tools` subdirectory then the `-File` argument must be updated to the following.\n\n```\n-File $(WIN32_AS_PROJECT_PATH)\\Logical\\Tools\\BuildVersion\\BuildVersion.ps1\n```\n\nThe Pre-Build Step will have to be set for all desired configurations.  \n\nUpon successful installation, users will see BuildVersion messages in the output results when building.\n\n![BuildVersion output results 2022-04-10_13 48 16](https://user-images.githubusercontent.com/33841634/162637580-277bd6a0-d40b-4da7-bd82-3082ee8f065e.png)\n\n## Errors\n\n\u003e The argument \"C:\\projects\\MyProject\\Logical\\BuildVersion\\BuildVersion.ps1\" to the -File parameter does not exist.\n\n- Possible cause: The pre-build event was created but the BuildVersion package was not added to the project. \n  - *Remedy*: Follow the [installation](#installation) instructions to add existing package to the project.\n- Possible cause: The pre-build event created but does not point to the BuildVersion package. \n  - *Remedy*: Update the [pre-build field's](#2-create-pre-build-event) script path `$(WIN32_AS_PROJECT_PATH)\\Logical\\BuildVersion\\BuildVersion.ps1` to match the path in the project\n\n\u003e Object \"C:\\projects\\MyProject\\Logical\\BuildVersion\\BuildVer\\Variable.var\" doesn't exist.\n\n- Possible cause: The BuildVersion package was added to the project, but the pre-build event was not created.\n  - *Remedy*: Follow the [installation](#2-create-pre-build-event) instructions to create the pre-build event.\n- Possible cause: The local task was renamed and the PowerShell script cannot find it.\n  - *Remedy*: Update the PowerShell script's `$ProgramName` parameter (default `\"BuildVer\"`) to match the task name in the project.\n\n\u003e BuildVersion: Git in not installed or unavailable in PATH environment  \n\u003e BuildVersion: Please install git (git-scm.com) with recommended options for PATH  \n\n- Possible cause: Using the git client Sourcetree with the embedded git preference.\n  - *Remedy*: Installing Sourcetree before installing git causes Sourcetree to default to its embedded git option. Sourcetree's embedded git is not available in the PATH environment. [Install git separately](https://git-scm.com/) with default installer options to add git to the PATH environment.\n\n## Developers\n\nThe [PowerShell script](https://github.com/br-na-pm/BuildVersion/blob/dd9dd64a9b23b1f31e800e7619e68b56a351374e/BuildVersion.ps1#L16) offers several optional [switch parameters](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.4#switch-parameters).\n\n`-ErrorOnRepository`\n\nCreate a build error if git is not installed of the project path does not exist within a git repository.\n\n`-ErrorOnChange`\n\nCreate a build error if the git repository shows uncommited changes.\n\n`-ErrorOnInitialization`\n\nCreate a build error if neither the local variable or global variable was updated with build information.\n\n`-PrintDebug`\n\nPrint all debug messages to the output results.\n\nTo run multiple commands in the pre-build event, use the follow syntax.\n\n```powershell\n\u003ccommand_1\u003e \u0026 \u003ccommand_2\u003e\n```\n\n## Build \n\nBuilding a project with this package may result in warnings for additional files.  \n\n![Build warnings 2022-03-31_12 34 35](https://user-images.githubusercontent.com/33841634/161134955-5e71050f-bd1b-49cf-b07c-6408ae3c24ca.png)\n\nIn Automation Studio 4.11+, it is possible to add specific filters to warnings 9232 and 9233.  Navigate to Configuration View, right-click the PLC object and select properties, chose the Build tab, and add the follow text to the \"Objects ignored for build warnings 9232 and 9233\" field. The filters are case sensitive.\n\n```\n*README*;*LICENSE*;.git;.gitignore;.github\n```\n\nPrior to Automation Studio 4.11, it is possible to suppress *all* build warnings regarding additional files by using `-W 9232 9233` in the \"Additional build options\" field.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbr-na-pm%2FBuildVersion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbr-na-pm%2FBuildVersion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbr-na-pm%2FBuildVersion/lists"}