- Setup
- Source Files used in the Module
- Module Build Process
- Publishing
SqlQueryClassModule to GitHub - Code Review and Feedback
- Merge the Pull Request
- Cleanup
- Publishing
SqlQueryClassModule to PowerShell Gallery
-
Uses SQL Express but should work with other SQL Databases with proper connection strings and credentials
-
Requires VS Code
-
For Contributors, Fork the SqlQueryClass repository
-
Clone the repository or fork to local pc. I like using c:\git as my local repository folder. Subfolder $ProjectName will be created with the GitHub repository contents
-
Install Manjunath Beli's ModuleTools module as the module build process uses ModuleTools
Find-Module -Name ModuleTools | Install-Module -Scope CurrentUser -Verbose
-
Note that a sample SQL Express database file (.\tests\TestDatabase1.mdf) is included for pester tests. The database configuration is set in .\tests\TestDatabase1.parameters.psd1
- Public functions that are exported, are separate files in the .\src\public folder.
- Private functions that are local to the Module, are separate files in the .\src\private folder.
-
- Class Definitions and Enums are not accessible outside of the Module and cannot be accessed directly like Public Functions are. This is a PowerShell limitation.
-
-
- Classes [SqlQueryDataSet] and [SqlQueryDataSetParms] and enum ResultType used in the Module are defined in file .\src\private\SqlQueryClass.ps1 file. The classes have properties and methods used to maintain a Database connections and result sets making it useful WPF Data binding.
-
- Resources are files and folders in the .\src\resources folder that needs to be included with the Manifest and Module
- Create a local branch for your changes.
-
- Use descriptive name that reflects the type of changes for branch for example features/database-table-access
git checkout -b features/database-table-access
-
Update the build version using Update-MTModuleVersion (Find-Module -Name ModuleTools).
-
Commit your changes to the branch.
-
Run the Pester Tests using Invoke-MTTest (Find-Module -Name ModuleTools).
-
Build the Module output using Invoke-MTBuild -Verbose (Find-Module -Name ModuleTools).
Invoke-MTBuild -Verbose
-
- Outputs to the .\dist\SqlQueryClass folder
-
- Combines the file contents of the files in Public and Private folder into .\dist\SqlQueryClass\SqlQueryClass.psd1 and exports the Public Functions
-
- Generates the .\dist\SqlQueryClass\SqlQueryClass.psd1 Manifest file from the settings in .\project.json
-
- Resources (.\src\resources) folder content is copied to .\dist\SqlQueryClass folder
- Run the Pester Teats using Invoke-MTTest (Find-Module -Name ModuleTools)
- Make corrections, repeat the build process.
- For Contributors:
- Create an Issue if one does not exist that addresses the proposed changes.
- Upstream your branch.
- Create a Pull request.
-
Stage and Commit Your Changes
git add . git commit -m "Implemented database and table access functions"
-
Update remote repository with branch changes
# List status of remote repository git branch -r # Create Branch on remote repository if needed # git push --set-upstream origin features/database-table-access # Push branch changes to remote branch in repository git push origin features/database-table-access
-
Create a Pull Request on remote repository
- Go to SqlQueryClass GitHub repository
- Click on "Compare & pull request" for your branch
- Provide a meaningful title and description for the PR
- Select the base branch (main) to merge into
- Click "Create pull request"
- Engage with Repository Owner or collaborators to review the PR
- Address any feedback or requested changes by making additional commits to your branch and pushing them to the remote branch
- Ensure the PR passes any automated tests or checks
- Once the PR is approved and all checks pass, you can merge it into the main branch
- You can either use the "Merge pull request" button on GitHub or merge it locally and push the changes
- After merging, you can delete the feature branch from the remote repository to keep it clean
git push origin --delete features/database-table-access- Optionally, delete the local branch
git branch -d features/database-table-accessThese steps will ensure your changes are integrated into the main branch and your repository remains organized.
$data = Get-MTProjectInfo
$ApiKey = "your-api-key-here"
Publish-Module -Path $data.OutputModuleDir -NuGetApiKey $ApiKey -Repository PSGallery