Use relative paths for working directory & start in C# project

Edit directly in the .csproj file without escaping the characters, like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <ProjectView>ProjectFiles</ProjectView>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <StartAction>Program</StartAction>
    <StartWorkingDirectory>$(SolutionDir)..\..\..\..\mydir</StartWorkingDirectory>
    <StartProgram>$(SolutionDir)..\..\dir\myapplication.exe</StartProgram>
  </PropertyGroup>
</Project>

Also there is no need for the slash after $(SolutionDir)

enter image description here


I know this might sound the same as others, I just want to be clear you did exactly this.

You should

  1. close visual studio - it's important as it might override your file if you keep it open
  2. open myproject.csproj.user using notepad.
  3. enter this

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <ProjectView>ProjectFiles</ProjectView>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
        <StartAction>Program</StartAction>
        <StartWorkingDirectory>$(SolutionDir)..\..\..\..\mydir</StartWorkingDirectory>
        <StartProgram>$(SolutionDir)..\..\dir\myapplication.exe</StartProgram>
      </PropertyGroup>
    </Project>
    
  4. Close notepad

  5. Open Visual Studio
  6. Go to project properties and confim you see this enter image description here