Skip to content

Commit

Permalink
Make compatible with macOS and VS Code Insiders
Browse files Browse the repository at this point in the history
  • Loading branch information
jfversluis committed Nov 8, 2024
1 parent 74aad31 commit 906f5ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 13 additions & 3 deletions src/Templates/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}

0 comments on commit 906f5ee

Please sign in to comment.