Created
May 9, 2015 01:49
-
-
Save nikolay-pshenichny/560905f7e8c300895686 to your computer and use it in GitHub Desktop.
Modify "Conditional compilation symbols" from NuGet install.ps1 script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($installPath, $toolsPath, $package, $project) | |
if ($project -ne $null) | |
{ | |
$configuration = $project.ConfigurationManager | Where-Object {$_.ConfigurationName -eq "Debug"} | |
if ($configuration -ne $null) | |
{ | |
$oldValue = $configuration.Properties.Item("DefineConstants").Value | |
$newValue = $newValue + ";" + "HELLO_WORLD" | |
$configuration.Properties.Item("DefineConstants").Value = $newValue | |
} | |
$project.Save() | |
} | |
# Notes: | |
# - This example is way to simplistic | |
# | |
# Required modifications: | |
# - check if the Symbol that you want to inject is already there. | |
# - check $project.IsDirty if needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In Package Manager Console: | |
$dte = [System.Runtime.InteropServices.Marshal]::GetActiveObject("VisualStudio.DTE.12.0") | |
$p = $dte.Solution.Projects | Where-Object {$_.ProjectName -eq "YourProjectName"} | |
# OR | |
$p = Get-Project | |
# And then... | |
$c = $p.ConfigurationManager | where-object {$_.ConfigurationName -eq "Release"} | |
$oldValue = $c.Properties.Item("DefineConstants").Value | |
$newValue = $oldValue + ";HELLO_WORLD" | |
$c.Properties.Item("DefineConstants").Value = $newValue | |
$p.Save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment