Skip to content

Commit 3e69fc7

Browse files
authored
add visual studio project template (#17)
1 parent 354c450 commit 3e69fc7

File tree

15 files changed

+220
-65
lines changed

15 files changed

+220
-65
lines changed

.github/workflows/reusable-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
- uses: actions/checkout@v3
1111
- name: Build package
1212
shell: pwsh
13-
run: ./Build-Installer.ps1
13+
run: ./JetBrainsMono/Build-Installer.ps1
1414
env:
1515
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1616
- uses: actions/upload-artifact@v3
1717
with:
1818
name: build
19-
path: JetBrainsMonoNF/bin/Release/*.msi
19+
path: JetBrainsMono/bin/Release/*.msi
2020
if-no-files-found: error

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,3 @@ FodyWeavers.xsd
396396

397397
# JetBrains Rider
398398
*.sln.iml
399-
400-
JetBrainsMonoNF/Fonts/
401-
*.zip
402-
Directory.wxs
403-
Product.wxs

JetBrainsMonoNF.sln renamed to JetBrainsMono.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.5.33530.505
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "JetBrainsMonoNF", "JetBrainsMonoNF\JetBrainsMonoNF.wixproj", "{AAC181ED-E019-41E6-A205-D1C183600171}"
6+
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "JetBrainsMono", "JetBrainsMono\JetBrainsMono.wixproj", "{AAC181ED-E019-41E6-A205-D1C183600171}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution

JetBrainsMono/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fonts/
2+
*.zip
3+
Directory.wxs
4+
Product.wxs

Build-Installer.ps1 renamed to JetBrainsMono/Build-Installer.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ $asset = $Matches.url
66

77
Invoke-WebRequest -Uri $asset -OutFile $PSScriptRoot\JetBrainsMono.zip
88
Remove-Item `
9-
-Path $PSScriptRoot\JetBrainsMonoNF\Fonts `
9+
-Path $PSScriptRoot\Fonts `
1010
-Recurse `
1111
-Force `
1212
-ErrorAction SilentlyContinue
1313
New-Item `
14-
-Path $PSScriptRoot\JetBrainsMonoNF\Fonts `
14+
-Path $PSScriptRoot\Fonts `
1515
-ItemType Directory
1616
Expand-Archive `
1717
-Path $PSScriptRoot\JetBrainsMono.zip `
18-
-DestinationPath $PSScriptRoot\JetBrainsMonoNF\Fonts `
18+
-DestinationPath $PSScriptRoot\Fonts `
1919
-Force
2020
Remove-Item `
21-
-Path $PSScriptRoot\JetBrainsMonoNF\Fonts\* `
21+
-Path $PSScriptRoot\Fonts\* `
2222
-Exclude *Windows*
2323

2424
$asset -match '/v(?<version>[\d.]+)/'
2525
$version = $Matches.version
2626

27-
(Get-Content -Path $PSScriptRoot\JetBrainsMonoNF\Product.xml) `
27+
(Get-Content -Path $PSScriptRoot\Product.xml) `
2828
-creplace '(\bVersion=)"[\d.]+"', ('$1"' + $version + '"') `
29-
> $PSScriptRoot\JetBrainsMonoNF\Product.wxs
29+
> $PSScriptRoot\Product.wxs
3030

3131
msbuild /p:Configuration=Release `
32-
$PSScriptRoot\JetBrainsMonoNF\JetBrainsMonoNF.wixproj
32+
$PSScriptRoot\JetBrainsMono.wixproj
Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6-
<ProductVersion>3.10</ProductVersion>
7-
<ProjectGuid>aac181ed-e019-41e6-a205-d1c183600171</ProjectGuid>
8-
<SchemaVersion>2.0</SchemaVersion>
9-
<OutputName>JetBrainsMonoNF</OutputName>
10-
<OutputType>Package</OutputType>
11-
<DefineSolutionProperties>false</DefineSolutionProperties>
12-
</PropertyGroup>
13-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
14-
<OutputPath>bin\$(Configuration)\</OutputPath>
15-
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
16-
<DefineConstants>Debug;FontsDirectory=fonts</DefineConstants>
17-
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
19-
<OutputPath>bin\$(Configuration)\</OutputPath>
20-
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
21-
<DefineConstants>FontsDirectory=Fonts</DefineConstants>
22-
</PropertyGroup>
23-
<ItemGroup>
24-
<Compile Include="Directory.wxs" />
25-
<Compile Include="Product.wxs" />
26-
</ItemGroup>
27-
<ItemGroup>
28-
<Content Include="Product.xml" />
29-
<Content Include="TrueType.xsl" />
30-
</ItemGroup>
31-
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
32-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
33-
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
34-
<Error Text="The WiX Toolset v3.11 build tools must be installed to build this project. To download the WiX Toolset, see https://wixtoolset.org/releases/v3.11/stable" />
35-
</Target>
36-
<PropertyGroup>
37-
<PreBuildEvent>"%WIX%bin\heat" dir $(ProjectDir)fonts -ag -cg ProductComponents -sfrag -srd -sreg -scom -var var.FontsDirectory -dr FontsFolder -t $(ProjectDir)TrueType.xsl -out $(ProjectDir)Directory.wxs</PreBuildEvent>
38-
</PropertyGroup>
39-
<!--
40-
To modify your build process, add your task inside one of the targets below and uncomment it.
41-
Other similar extension points exist, see Wix.targets.
42-
<Target Name="BeforeBuild">
43-
</Target>
44-
<Target Name="AfterBuild">
45-
</Target>
46-
-->
47-
</Project>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>3.10</ProductVersion>
7+
<ProjectGuid>aac181ed-e019-41e6-a205-d1c183600171</ProjectGuid>
8+
<SchemaVersion>2.0</SchemaVersion>
9+
<OutputName>JetBrainsMono</OutputName>
10+
<OutputType>Package</OutputType>
11+
<DefineSolutionProperties>false</DefineSolutionProperties>
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
14+
<OutputPath>bin\$(Configuration)\</OutputPath>
15+
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
16+
<DefineConstants>Debug;FontsDirectory=fonts</DefineConstants>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
19+
<OutputPath>bin\$(Configuration)\</OutputPath>
20+
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
21+
<DefineConstants>FontsDirectory=Fonts</DefineConstants>
22+
</PropertyGroup>
23+
<ItemGroup>
24+
<Compile Include="Directory.wxs" />
25+
<Compile Include="Product.wxs" />
26+
</ItemGroup>
27+
<ItemGroup>
28+
<Content Include="Build-Installer.ps1" />
29+
<Content Include="Product.xml" />
30+
<Content Include="TrueType.xsl" />
31+
</ItemGroup>
32+
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
33+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
34+
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
35+
<Error Text="The WiX Toolset v3.11 build tools must be installed to build this project. To download the WiX Toolset, see https://wixtoolset.org/releases/v3.11/stable" />
36+
</Target>
37+
<PropertyGroup>
38+
<PreBuildEvent>"%WIX%bin\heat" dir $(ProjectDir)fonts -ag -cg ProductComponents -sfrag -srd -sreg -scom -var var.FontsDirectory -dr FontsFolder -t $(ProjectDir)TrueType.xsl -out $(ProjectDir)Directory.wxs</PreBuildEvent>
39+
</PropertyGroup>
40+
<!--
41+
To modify your build process, add your task inside one of the targets below and uncomment it.
42+
Other similar extension points exist, see Wix.targets.
43+
<Target Name="BeforeBuild">
44+
</Target>
45+
<Target Name="AfterBuild">
46+
</Target>
47+
-->
48+
</Project>
File renamed without changes.
File renamed without changes.

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,21 @@ Start-Process `
2222

2323
## Build
2424

25-
Run the `Build-Installer.ps1` PowerShell script to build the installer.
25+
Run the `JetBrainsMono\Build-Installer.ps1` PowerShell script to build the
26+
installer.
2627

27-
If successful, the MSI file will be available in the
28-
`JetBrainsMonoNF\bin\Release` directory.
28+
If successful, the MSI file will be available in the `JetBrainsMono\bin\Release`
29+
directory.
30+
31+
## Visual Studio project template
32+
33+
You can use the included [Visual Studio project
34+
template](https://learn.microsoft.com/visualstudio/ide/creating-project-and-item-templates)
35+
to build an installer for a Nerd Font of your choice. To use the template, zip
36+
the files in the `VSTemplate` folder and copy it to your `%USERPROFILE%\
37+
Documents\Visual Studio 2022\Templates\ProjectTemplates` folder.
38+
39+
After installing the template, create a new Visual Studio project using it, and
40+
name the project with the name of one of the zip files available for download in
41+
the [releases page](https://github.com/ryanoasis/nerd-fonts/releases) of the
42+
Nerd Font GitHub repository.

VSTemplate/Build-Installer.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
(gh release view -R ryanoasis/nerd-fonts --json assets) `
4+
-match '(?<url>https://[^"]+?$safeprojectname$\.zip)"'
5+
$asset = $Matches.url
6+
7+
Invoke-WebRequest -Uri $asset -OutFile $PSScriptRoot\$safeprojectname$.zip
8+
Remove-Item `
9+
-Path $PSScriptRoot\Fonts `
10+
-Recurse `
11+
-Force `
12+
-ErrorAction SilentlyContinue
13+
New-Item `
14+
-Path $PSScriptRoot\Fonts `
15+
-ItemType Directory
16+
Expand-Archive `
17+
-Path $PSScriptRoot\$safeprojectname$.zip `
18+
-DestinationPath $PSScriptRoot\Fonts `
19+
-Force
20+
Remove-Item `
21+
-Path $PSScriptRoot\Fonts\* `
22+
-Exclude *Windows*
23+
24+
$asset -match '/v(?<version>[\d.]+)/'
25+
$version = $Matches.version
26+
27+
(Get-Content -Path $PSScriptRoot\Product.xml) `
28+
-creplace '(\bVersion=)"[\d.]+"', ('$1"' + $version + '"') `
29+
> $PSScriptRoot\Product.wxs
30+
31+
msbuild /p:Configuration=Release `
32+
$PSScriptRoot\$safeprojectname$.wixproj

0 commit comments

Comments
 (0)