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

a 夏天 提交于 2019-12-24 19:11:17

问题


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.


回答1:


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.




回答2:


The default output directory is :

$(SolutionDir)$(Configuration)\

So by default, output binaries will be created in:

Path\To\Your\Solution\[Configuration]\.

Configuration can be something like "Debug" or "Release".

Depending on your project settings, these directories can vary. You can see/change those settings in :

Menu Project -> Properties -> Configuration Properties -> General -> Output Directory


来源:https://stackoverflow.com/questions/52661233/set-output-build-path-for-visual-studio-2017-per-user-with-vars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!