Skip to content

Instantly share code, notes, and snippets.

@xt0rted
Created July 14, 2014 19:32
Show Gist options
  • Save xt0rted/e2d233385ee9f5cba3c0 to your computer and use it in GitHub Desktop.
Save xt0rted/e2d233385ee9f5cba3c0 to your computer and use it in GitHub Desktop.
Nancy.Viewengines.Razor.0.23.0
param($installPath, $toolsPath, $package, $project)
. (Join-Path $toolsPath "GetNancyRazorBuildProviderPostBuildCmd.ps1")
# Get the current Post Build Event cmd
$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value
# Append our post build command if it's not already there
if (!$currentPostBuildCmd.Contains($NancyRazorBuildProviderPostBuildCmd)) {
$project.Properties.Item("PostBuildEvent").Value += $NancyRazorBuildProviderPostBuildCmd
}
function Get-VsFileSystem {
$componentModel = Get-VSComponentModel
$fileSystemProvider = $componentModel.GetService([NuGet.VisualStudio.IFileSystemProvider])
$solutionManager = $componentModel.GetService([NuGet.VisualStudio.ISolutionManager])
$fileSystem = $fileSystemProvider.GetFileSystem($solutionManager.SolutionDirectory)
return $fileSystem
}
$projectRoot = $project.Properties.Item("FullPath").Value
if (!$projectRoot) {
return;
}
$destDirectory = $projectRoot
$fileSystem = Get-VsFileSystem
$file = Join-Path $installPath "content\web.config.transform"
ls $file -Filter *.transform | %{
$destPath = Join-Path $destDirectory "web.config"
if (!(Test-Path $destPath)) {
$fileStream = $null
try {
$fileStream = [System.IO.File]::OpenRead($_.FullName)
$fileSystem.AddFile($destPath, $fileStream)
$project.ProjectItems.AddFromFile($destPath)
} catch {
# We don't want an exception to surface if we can't add the file for some reason
} finally {
if ($fileStream -ne $null) {
$fileStream.Dispose()
}
}
}
}
param($installPath, $toolsPath, $package, $project)
. (Join-Path $toolsPath "GetNancyRazorBuildProviderPostBuildCmd.ps1")
# Get the current Post Build Event cmd
$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value
# Remove our post build command from it (if it's there)
$project.Properties.Item("PostBuildEvent").Value = $currentPostBuildCmd.Replace($NancyRazorBuildProviderPostBuildCmd, "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment