Search code examples
c#msbuildvisual-studio-2017visual-studio-2017-build-tools

Set output build path for Visual Studio 2017 per user with vars


I am trying to change the output path for build per user. I want to redirect output to Ram Disk. After many attempts i finished with something like that:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <OutputPath>R:\VisualStudioBuilds\MyProjectName\bin\$(Configuration)\</OutputPath>
  </PropertyGroup>
</Project>

But the project name is hardcoded! To change this situation i have tried another solution:

<OutputPath>R:\VisualStudioBuilds\$(ProjectName)\bin\$(Configuration)\</OutputPath>

And this doesn't work. In the end the build path is R:\VisualStudioBuilds\bin\Debug. I have also tried out another variables like ProjectDir, RootNameSpace and other but still no success.

What should I do to make it work? Remember, any modification should be in .csproj.user not to team-shared .csproj.


Solution

  • What should I do to make it work? Remember, any modification should be in .csproj.user not to team-shared .csproj.

    Sorry for this delayed reply, but hope this can give you some helps.

    To accomplish this issue, you can use property $(AssemblyName) instead of $(ProjectName), so the settings in the .csproj.user looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <OutputPath>R:\VisualStudioBuilds\$(AssemblyName)\bin\$(Configuration)\</OutputPath>
      </PropertyGroup>
    </Project>
    

    That should be works for you.

    Hope this helps.