You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For easy building and testing you can use the `build.ps1` script. This script is only for manual use and not part of any pipeline.
5
5
6
-
Add the local artifacts to the NuGet.config:
6
+
> [!NOTE]
7
+
> On macOS you find encounter and error like: `error NU5119: Warning As Error: File '/file/path/.DS_Store' was not added to the package. Files and folders starting with '.' or ending with '.nupkg' are excluded by default. To include this file, use -NoDefaultExcludes from the commandline` when this happens, run a `git clean -xfd` on the repository to remove all `.DS_Store` files from the filesystem.
dotnet new uninstall Microsoft.Maui.Templates.net8
15
-
dotnet pack Microsoft.Maui.sln
16
-
dotnet new install artifacts\packages\Release\Shipping\Microsoft.Maui.Templates.*.nupkg
11
+
The script:
12
+
* Deletes the `.tempTemplateOutput` folder which is used for the temporary files used by this script
13
+
* Builds the `src\Templates\src\Microsoft.Maui.Templates.csproj` project
14
+
* Packs the `src\Templates\src\Microsoft.Maui.Templates.csproj` project into a .nupkg file and outputs it to the `.tempTemplateOutput` directory, this directly is excluded from git
15
+
* Uninstalls any previous manual installations of .NET MAUI templates
16
+
* Empties the `~\templateengine` folder
17
+
* Finds and installs the resulting .nupkg artifact in the `.tempTemplateOutput` directory
18
+
* Creates a new .NET MAUI project based on the latest changes in the template
19
+
* Opens the new .NET MAUI project in Visual Studio (or on Mac in Visual Studio Code)
17
20
18
-
# then just in the maui folder, so you get a NuGet.config
19
-
mkdir myproject
20
-
cd myproject
21
-
dotnet new maui
22
-
```
21
+
## Parameters
22
+
23
+
The script defines a coupe of parameters you can use. All have default values, so you only have to set them whenever you want to deviate from the default behavior.
24
+
25
+
The parameters are as follows:
26
+
27
+
*`projectType`: Specifies the type of .NET project to create (default is `maui`).
28
+
*`templateVersion`: Specifies the version number to use for the template pack build (default is `13.3.7`, needs to be a valid major, minor, patch version number, for example 1.2.3).
29
+
*`templatesProjectPath`: Specifies the path to the template project to build (default is `src\Microsoft.Maui.Templates.csproj`).
30
+
*`startVsAfterBuild`: Specifies whether to start Visual Studio (Code) after creating the new project with the latest template changes (default is `true`).
31
+
32
+
### Example usage with parameters
33
+
34
+
Find sample usages of the different parameters below, of course these can be mixed and matched as needed.
35
+
36
+
* Instead of a default .NET MAUI app, use the Blazor Hybrid template: `.\build.ps1 -projectType maui-blazor`
37
+
* Set a custom version number for the template: `.\build.ps1 -templateVersion 1.2.3`
38
+
* Build another template project: `.\build.ps1 -templatesProjectPath src\Microsoft.Maui.Templates-new.csproj`
39
+
* Don't start VS after creating the new project using the latest template changes: `.\build.ps1 -startVsAfterBuild $false`
[Parameter(Mandatory=$false,HelpMessage="Specify whether to start Visual Studio (Code) after creating the new project with the latest template changes")]
9
+
[bool]$startVsAfterBuild=$true
10
+
)
2
11
3
-
& dotnet new -u "Microsoft.Maui.Templates"
4
-
# & dotnet new -u "../../artifacts/Microsoft.Maui.Templates.$PACKAGEVERSION.nupkg"
12
+
# Source the utils script for some common functionalities
13
+
. .\eng\utils.ps1
5
14
6
-
if (Test-Path"../../artifacts/Microsoft.Maui.Templates.*.nupkg") {
Write-Error"Neither Visual Studio Code Insiders nor Visual Studio Code stable is installed. Cannot open VS Code, however a new project is created at $projectFolderPath."
0 commit comments