Private/Cs/WebProj/New-MvcAngularProject.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Function New-MvcAngularProject([SolnInfo] $solnInfo, [WebCsprojInfo] $webCsprojInfo)
{
    Write-Host "### Making MVC Angular project" $webCsprojInfo.csprojName
    &{dotnet new angular -n $webCsprojInfo.csprojName -o $webCsprojInfo.csprojDir}
    Confirm-LastExitCode

    # Add proj to soln
    Write-Host "### Add" $webCsprojInfo.csprojName "to solution" $solnInfo.nickName
    &{dotnet sln $solnInfo.solnFile add $webCsprojInfo.csprojFile}
    Confirm-LastExitCode

    # Add nuget packages
    Write-Host "### Add nuget packages to" $webCsprojInfo.csprojName
    &{dotnet add $webCsprojInfo.csprojFile package BoxTurtleCs }
    Confirm-LastExitCode

    Write-Host "### Microsoft wants us to run npm install"
    [string] $curDir = Get-Location
    try {
        Set-Location $webCsprojInfo.csprojDir
        &{npm install}
    } finally {
        Set-Location $curDir
    }
    Confirm-LastExitCode

}