visual_studio_writer: Make OutDir equal to $(SolutionDir). Currently gn writes relative path as 'OutDir' in Visual Studio project, this is problematic because changing working directory for debug purposes leads to inability to launch an executable. Instead gn should either write absoulte directory or similarly to default Visual Studio configuration for the project use project/solution specific variables. By default VS generates the following 'OutDir' for its project $(SolutionDir)$(Platform)\$(Configuration)\ but for gn position of executable seems to always be equal to $(SolutionDir) currently. So writing just $(SolutionDir) should work as well as current way and would not be disrupted by changing working directory. Change-Id: I4ad0394287c8e6ccde1f4fd74762cc9650994463 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/4420 Reviewed-by: Brett Wilson <brettw@chromium.org> Commit-Queue: Brett Wilson <brettw@chromium.org>
diff --git a/tools/gn/visual_studio_writer.cc b/tools/gn/visual_studio_writer.cc index c4fd906..7033358 100644 --- a/tools/gn/visual_studio_writer.cc +++ b/tools/gn/visual_studio_writer.cc
@@ -518,11 +518,7 @@ std::unique_ptr<XmlElementWriter> properties = project.SubElement("PropertyGroup"); { - std::unique_ptr<XmlElementWriter> out_dir = - properties->SubElement("OutDir"); - path_output.WriteDir(out_dir->StartContent(false), - build_settings_->build_dir(), - PathOutput::DIR_INCLUDE_LAST_SLASH); + properties->SubElement("OutDir")->Text("$(SolutionDir)"); } properties->SubElement("TargetName")->Text("$(ProjectName)"); if (target->output_type() != Target::GROUP) {