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.
NuGet install.ps1 script that overwrites existing file
param($installPath, $toolsPath, $package, $project)
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" }
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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment