diff --git a/src/Templates/README.md b/src/Templates/README.md index bcad31bff3..c2b72b94a4 100644 --- a/src/Templates/README.md +++ b/src/Templates/README.md @@ -3,6 +3,9 @@ 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. +> [!NOTE] +> 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. + ## Functionality The script: diff --git a/src/Templates/build.ps1 b/src/Templates/build.ps1 index e7d3c80d48..e56ef9186f 100644 --- a/src/Templates/build.ps1 +++ b/src/Templates/build.ps1 @@ -39,20 +39,30 @@ Empty-UserHomeTemplateEngineFolder dotnet new install $nupkgPath.FullName # Create a new dotnet project using the specified project type -dotnet new $projectType -o .tempTemplateOutput\NewProject --force +dotnet new $projectType -o ./.tempTemplateOutput/NewProject --force if ($startVsAfterBuild -eq $false) { exit 0 } # Start Visual Studio with the newly created project -$projectFilePath = Resolve-Path ".\.tempTemplateOutput\NewProject\NewProject.csproj" +$projectFilePath = Resolve-Path "./.tempTemplateOutput/NewProject/NewProject.csproj" $projectFolderPath = Split-Path -Path $projectFilePath if ([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows)) { Start-Process "devenv.exe" -ArgumentList $projectFilePath } elseif ([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::OSX)) { - Start-Process "code" -ArgumentList $projectFolderPath + # Check if VS Code Insiders is installed + $vscodeInsidersPath = "/Applications/Visual Studio Code - Insiders.app" + $vscodeStablePath = "/Applications/Visual Studio Code.app" + + if (Test-Path $vscodeInsidersPath) { + Start-Process "code-insiders" -ArgumentList $projectFolderPath + } elseif (Test-Path $vscodeStablePath) { + Start-Process "code" -ArgumentList $projectFolderPath + } else { + 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." + } } else { Write-Error "Unsupported operating system." } \ No newline at end of file