Skip to content

Instantly share code, notes, and snippets.

@Balder1840
Forked from jchadwick/install.ps1
Created March 30, 2018 05:08
Show Gist options
  • Select an option

  • Save Balder1840/868cd9175a74aa87dc921101233b9aa3 to your computer and use it in GitHub Desktop.

Select an option

Save Balder1840/868cd9175a74aa87dc921101233b9aa3 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