I'm writing a VSIX package to allow the user to bulk-edit the OutputPath property of all the active configurations of projects in the currently loaded solution (see the incredibly annoying step #4 here).
I ran into a very specific problem: when setting the property to a value containing macros (e.g. "$(SolutionDir)\bin\Debug"
the value written into the .csproj is escaped as follows:
<OutputPath>%24%28SolutionDir%29\bin\Debug\</OutputPath>
Which, rather than letting MSBuild expand the macro, creates an actual physical folder named $(SolutionDir)
. I'd like to somehow bypass this escaping.
The MSDN documentation is unsurprisingly lacking in that area.
My initial code is as follows:
private void MenuItemCallback(object sender, EventArgs e)
{
SolutionWideOutputDialogWindow dialog = new SolutionWideOutputDialogWindow();
dialog.ShowModal();
if (!dialog.DialogResult.HasValue || !dialog.DialogResult.Value)
{
return;
}
string requestedOutputPath = dialog.outputPathTextBox.Text;
Solution2 solution = _dte2.Solution as Solution2;
if (solution == null)
{
return;
}
Projects projects = solution.Projects;
foreach (Project project in projects)
{
Property outputPath = project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath");
outputPath.Value = requestedOutputPath;
project.Save();
}
}
Greatly appreciate anyone's help.
..\bin\debug
. – Porphyroid$(VCTargetsPath)\Platforms\Win32\ImportBefore
). Set OutputPath in the global one and you're done. I really recommend using a common file for defining pretty much everything (compiler/linker/tools options and all paths) anyway, it's a matter of DRY after all. – Hamlani