We’re back this week discussing another option for managing your .NET ScriptLink code: GitHub. GitHub is a popular platform for managing code, especially for open sources project. My first attempt at an open source ScriptLink library was managed there and is still available. I even manage my addon for World of Warcraft on GitHub. However, GitHub is not just for open source projects.
With GitHub you can create private repositories like we did last week using Azure DevOps. Private repositories are free for personal ones. If you want to establish an organization on GitHub then private repositories will require a subscription fee. This is part of the reason why I tend to use GitHub for my public repositories and Azure DevOps for the private ones, though not exclusively.
My recommendation for organizations is to create an organization to host your repositories so that you can manage staff and vendor changes. I did this with my second open source ScriptLink library, which was created and maintained while I was with Rebekah Children’s Services. Now the organization can transition the management to another staff member and the project isn’t sitting in one of my accounts.
Ok. Let’s do this.
What You Will Need
To follow this process, you will need the following:
- Visual Studio 2019
- A solution to commit/publish. (see previous articles)
- A GitHub Account
- An organization on GitHub. (optional)
I will be using an organization named “Rarely Simple” to publish this sample to. Here’s a small disclaimer. Rarely Simple is a brand for my personal tech blog and not a DBA.
Add Our Solution to Source Control
In the lower right of the Visual Studio interface you should see an option to “Add to Source Control.”
Let’s do that.
- Open our ScriptLink solution in Visual Studio, if not already opened.
- Select Add to Source Control in the lower right of the user interface.
- Select Git.
You will notice that the interface changes once the process is completed.
This is showing that that there are 2 unpublished commits and 0 pending changes.
- Under GitHub, select Publish to GitHub.
- Sign in to GitHub, if not logged in yet. (It also gives you the open to sign up at this point as well.)
- Select the account or organization you wish to use, if not already selected.
- Confirm the Repository name.
- If you want the repository to be private, check Private Repository.
- Select Publish.
When this process is completed, you should see a prompt reporting that the solution was pushed and the unpublished commits should now show 0 in the bottom right.
Commit a Change
Since we are using a project that was not committed to Azure DevOps last week (such as our Visual Basic version), then we should be able to make the same change to this project that we did last week. If the ICommand change describe below is already done, then rename the HelloWorld class and all of its references to HelloWorldCommand instead. This will help inform other developers that this is a ScriptLink command.
Ok. From last week. Our ICommand interface is potentially in conflict with the System.Windows.Input.ICommand interface and could cause confusion for other developers working on our project. So let’s rename it to IRunScriptCommand.
- Select Solution Explorer.
- Right-click on our ICommand.cs file and select Rename.
- Set name to IRunScriptCommand.cs and press Enter.
- When prompted to rename all references, select Yes.
- We should now see pending changes.
- Next, let’s run our Unit Tests and verify that all of the tests pass.
- If all went well everything should have passed.
- Next, we will commit our change.
- Select the pending commit at the bottom-right of the UI or select Test Explorer->Changes.
- Describe the change made and select Commit All.
- Once committed, you should see there is now 1 unpublished commit and 0 pending changes.
- Now let’s select the unpublished commit count in the bottom right or select Sync in the Team Explorer.
- Select sync to push the changes to our GitHub repo.
In my next articles, I will be discussing and demonstrating two deployment options that I recommend you consider for use in your environment. These methods eliminate traditional file transfers supporting automation and a reduction in deployment process-related errors. More on this next week.
Now that we have completed this step, you can see both the C# version of the ScriptLink solution we have been building as well as the Visual Basic version on GitHub. I have updated them beyond even the items discussed in the previous articles. Perhaps it can inspire ideas in your own solutions.