XmlNotepad Development#

You can build and test XML Notepad using Visual Studio 2022. It uses .NET frameworks, so be sure to install the ".NET desktop development" feature when using the Visual Studio Installer. XML Notepad targets .NET Framework version 4.8.

Coding Guidelines#

XmlNotepad follows the standard C# Coding Guidelines with the default C# formatting settings that ship with VS 2022.

The following additional conventions are also followed:

  1. All if/else statements use curly brackets.
  2. Add private/internal/public access explicitly on all members.
  3. Do not use "s_" prefix on statics, instead use Class name qualification.
  4. All private fields prefixed with _ except for WinForms generated code.
  5. Accessing fields with this. is ok, do not strip this. prefix if used.
  6. Constants are PascalCased even if they are private to a class.
  7. Try and collect all private fields at the top of the class.
  8. Public fields are PascalCased like public properties and methods.
  9. Generally one class per file, unless there is a super natural family of classes, like Commands.cs, that would cause an unnecessary explosion in number of files.
  10. Nice to have blank line between methods.
  11. Use "Remove and Sort Usings" command in VS.

Build the code#

First clone the repo:

git clone https://github.com/microsoft/XmlNotepad.git

From the command line initialize your ApiKey.cs file:

echo namespace XmlNotepad { public partial class AppAnalytics { private const string ApiKey="%XMLNOTEPAD_ANALYTICSKEY%"; } } > src\model\ApiKey.cs

Then restore all the nuget packages

nuget  restore xmlnotepad.sln

Then you can build it:

msbuild xmlnotepad.sln

Using Visual Studio:

Debug the app#

Test the app#

After building the app:

This is a GUI test, so do not move your mouse or type on your keyboard or let your screen lock until this test is completed. Total test run time is about 12 minutes.

The tests all pass on Windows 10, but currently some tests fail on Windows 11, there seems to be some breaking changes in the Windows Automation layer that XML notepad tests are using. This is being investigated.

Note: bug 10244 is still open in in .net 4.8 System.Windows.Automation of menu items that blocks the tests, so checkout the branch clovett/net472 to run the unit tests.


The UpdateVersions project synchronizes the Version.props information across multiple places so you can edit the version number in Version.props and this tool will replicate that across the following:

  1. The Version.cs file which sets the assembly version for all projects in the solution.
  2. The WIX based setup file Product.wxs.
  3. The windows package manifest file Package.appxmanifest.
  4. The updates.xml file.
  5. The readme.htm file.

You will also have to restart Visual Studio so that the new versions are picked up by the ClickOnce deployment information in Application.csproj.

Publish the app and all setups#

The publish.cmd script runs UpdateVersions, builds Release bits, builds the ClickOnce installer and the winget.msix installer from XmlNotepadPackage, and the standalone .msi installer from XmlNotepadSetup, it zips these files so they can be available on the Github Release page then it creates the new github release for the current version. It also signs the assemblies and installers using the signing certificate specified by the environment variable MYKEYFILE.

The ClickOnce installed is uploaded to lovettsoftware using the environment variable LOVETTSOFTWARE_STORAGE_CONNECTION_STRING. Click once is convenient because it provides auto-updating whenever a new version is published.

Build the setup .msi installer#

After building the Release configuration of XmlNotepad.sln load the XmlNotepadSetup.sln. This solution uses the WIX Toolset to build a standalone windows .msi installer. To build that setup you will need to install the WIX toolset then the Wix Toolset Visual Studio 2022 Extension.

Then right click the XmlNotepadSetup project and select "build". This will produce an .msi installer in the XmlNotepadSetup\bin\release folder. There is also a sign.cmd script invoked by this build that will try and sign the resulting .msi using the certificate installed by the author. This step will only work for the author who owns the certificate.

This msi installer gives folks the option to install XML Notepad on machines that are isolated from the internet and there are quite a few customers who have requested this, which is why it exists.

Build the winget setup package#

The winget setup package is built by the XmlNotepadPackage project in the XmlNotepadSetup.sln solution. Right click this project in the Solution Explorer and select Publish and Create App Packages. Choose Sideloading, and the package files will be written to the XmlNotepadPackage\AppPackages folder. These can then be uploaded to the server hosting these packages and you can then update the manifest in winget-pkgs.

This package provides the winget install xmlnotepad setup option.

Publishing the bits to Azure Blob Store#

The publish.cmd script uses the AzurePublishClickOnce tool which uses the environment variable named LOVETTSOFTWARE_STORAGE_CONNECTION_STRING to access the Azure storage account where it uploads the new clickonce installer, and removes the older versions so that the storage account does not keep growing and growing.


See XML Notepad Design for more detailed information about how this application is designed.


Feedback and suggestions are welcome, just use the GitHub issues list. Pull requests are also welcome, in fact, a number of good pull requests have already been merged. Thanks to all who are helping to make XML notepad a great tool!