Skip to content

Instantly share code, notes, and snippets.

@jchadwick
Created March 23, 2012 18:51
Show Gist options
  • Save jchadwick/2173751 to your computer and use it in GitHub Desktop.
Save jchadwick/2173751 to your computer and use it in GitHub Desktop.

Revisions

  1. jchadwick revised this gist Mar 26, 2012. 1 changed file with 13 additions and 7 deletions.
    20 changes: 13 additions & 7 deletions install.ps1
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,24 @@
    param($installPath, $toolsPath, $package, $project)

    #### Overwrite Global.asax ####
    Write-Host "Overwriting Global.asax..."
    Write-Host "Setting Application to DowJones.Web.Mvc.HttpApplication..."

    # Read the transformed text from the custom template included in the package
    $customGlobalAsax = $project.ProjectItems | where { $_.Name -eq "Global.asax.cs.custom" }
    $customGlobalAsax.Open()
    $customGlobalAsax.Document.Activate()
    $customGlobalAsax.Document.Selection.SelectAll();
    $replacementGlobalAsax = $customGlobalAsax.Document.Selection.Text;
    $customGlobalAsax.Delete()

    # Replace the contents of Global.asax.cs
    $globalAsax = $project.ProjectItems | ForEach-Object { $_.ProjectItems } | where { $_.Name -eq "Global.asax.cs" }
    $globalAsax.Open()
    $globalAsax.Document.Selection.SelectAll()
    $globalAsax.Document.Selection.Insert($replacementGlobalAsax)
    $globalAsax.Save()
    if($globalAsax) {
    $globalAsax.Open()
    $globalAsax.Document.Activate()
    $globalAsax.Document.Selection.SelectAll()
    $globalAsax.Document.Selection.Insert($replacementGlobalAsax)
    $globalAsax.Document.Selection.StartOfDocument()
    $globalAsax.Document.Close(0)
    } else {
    Write-Host "Global.asax.cs not found -- skipping application base type update"
    }
  2. jchadwick created this gist Mar 23, 2012.
    18 changes: 18 additions & 0 deletions install.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    param($installPath, $toolsPath, $package, $project)

    #### Overwrite Global.asax ####
    Write-Host "Overwriting Global.asax..."

    # Read the transformed text from the custom template included in the package
    $customGlobalAsax = $project.ProjectItems | where { $_.Name -eq "Global.asax.cs.custom" }
    $customGlobalAsax.Open()
    $customGlobalAsax.Document.Selection.SelectAll();
    $replacementGlobalAsax = $customGlobalAsax.Document.Selection.Text;
    $customGlobalAsax.Delete()

    # Replace the contents of Global.asax.cs
    $globalAsax = $project.ProjectItems | ForEach-Object { $_.ProjectItems } | where { $_.Name -eq "Global.asax.cs" }
    $globalAsax.Open()
    $globalAsax.Document.Selection.SelectAll()
    $globalAsax.Document.Selection.Insert($replacementGlobalAsax)
    $globalAsax.Save()