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.
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:
_ except for WinForms generated code.this. is ok, do not strip this. prefix if used.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:
src/XmlNotepad.sln into Visual Studio.Application project and select Set as Startup Project.After building the app:
UnitTests project and select Run tests.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:
Version.cs file which sets the assembly version for all projects in the solution.Product.wxs.Package.appxmanifest.You will also have to restart Visual Studio so that the new versions are picked up by the ClickOnce deployment
information in Application.csproj.
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.
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.
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.
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!