Categories
Uncategorized

Managing Your .NET ScriptLink Code with GitHub

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.

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:

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.”

Screenshot of ScriptLink Unit Tests Passing
ScriptLink Unit Tests Passing

Let’s do that.

  1. Open our ScriptLink solution in Visual Studio, if not already opened.
  2. Select Add to Source Control in the lower right of the user interface.
  3. Select Git.

You will notice that the interface changes once the process is completed.

Screenshot showing local Git repo created in Visual Studio 2019
Local Git repo created in Visual Studio 2019

This is showing that that there are 2 unpublished commits and 0 pending changes.

Screenshot of Push options in Visual Studio
Push options in Visual Studio
  1. Under GitHub, select Publish to GitHub.
  2. Sign in to GitHub, if not logged in yet. (It also gives you the open to sign up at this point as well.)
  3. Select the account or organization you wish to use, if not already selected.
  4. Confirm the Repository name.
  5. If you want the repository to be private, check Private Repository.
  6. 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.

  1. Select Solution Explorer.
  2. Right-click on our ICommand.cs file and select Rename.
  3. Set name to IRunScriptCommand.cs and press Enter.
  4. When prompted to rename all references, select Yes.
  5. We should now see pending changes.
Screenshot of Pending changes shown in Visual Studio 2019
Pending changes shown in Visual Studio 2019
  1. Next, let’s run our Unit Tests and verify that all of the tests pass.
  2. If all went well everything should have passed.
Screenshot of Unit Tests passing after Interface rename
Unit Tests passing after Interface rename
  1. Next, we will commit our change.
  2. Select the pending commit at the bottom-right of the UI or select Test Explorer->Changes.
  3. Describe the change made and select Commit All.
Screenshot of committing a change in Visual Studio
Committing a change in Visual Studio
  1. Once committed, you should see there is now 1 unpublished commit and 0 pending changes.
Screenshot of Unpushed Commit in Visual Studio
Unpushed Commit in Visual Studio
  1. Now let’s select the unpublished commit count in the bottom right or select Sync in the Team Explorer.
Screenshot of Synchronizing local repo with remote repo in Visual Studio 2019
Synchronizing local repo with remote repo in Visual Studio 2019
  1. Select sync to push the changes to our GitHub repo.

What Next?

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.