Visual Studio 2017创建空的输出文件夹

时间:2019-03-01 15:21:06

标签: visual-studio visual-studio-2017

给出VS解决方案的内容( Solution.sln )内容:

...
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SomeModule1", "SomeModule1\SomeModule1.csproj", "{SomeModule1 GUID}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SomeModule2", "SomeModule2\SomeModule2.csproj", "{SomeModule2 GUIDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SomeModuleX", "SomeModuleX\SomeModuleX.csproj", "{SomeModuleX GUID}"
EndProject
...
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug_X|Any CPU = Debug_X|Any CPU
        Debug_2|Any CPU = Debug_2|Any CPU
        Debug_1|Any CPU = Debug_1|Any CPU
        ...
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {SomeModule2 GUID}.Debug_X|Any CPU.ActiveCfg = Debug_X|Any CPU
        {SomeModule2 GUID}.Debug_X|Any CPU.Build.0 = Debug_X|Any CPU
        {SomeModuleX GUID}.Debug_X|Any CPU.ActiveCfg = Debug_X|Any CPU
        {SomeModuleX GUID}.Debug_X|Any CPU.Build.0 = Debug_X|Any CPU
        ...
        {SomeModule1 GUID}.Debug_2|Any CPU.ActiveCfg = Debug_2|Any CPU
        {SomeModule1 GUID}.Debug_2|Any CPU.Build.0 = Debug_2|Any CPU
        {SomeModuleX GUID}.Debug_2|Any CPU.ActiveCfg = Debug_2|Any CPU
        {SomeModuleX GUID}.Debug_2|Any CPU.Build.0 = Debug_2|Any CPU
        ...
        {SomeModule1 GUID}.Debug_1|Any CPU.ActiveCfg = Debug_1|Any CPU
        {SomeModule1 GUID}.Debug_1|Any CPU.Build.0 = Debug_1|Any CPU
        {SomeModule2 GUID}.Debug_1|Any CPU.ActiveCfg = Debug_1|Any CPU
        {SomeModule2 GUID}.Debug_1|Any CPU.Build.0 = Debug_1|Any CPU
...

以及在解决方案中找到的 Standard.props 文件(此文件通过<Import Project="..\Standard.props" />导入每个VS项目中):

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug_1|AnyCPU'">
    ...
    <OutputPath>D:\ProjectPath1\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug_2|AnyCPU'">
    ...
    <OutputPath>D:\ProjectPath2\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug_X|AnyCPU'">
    ...
    <OutputPath>D:\ProjectPathX\</OutputPath>
  </PropertyGroup>
 ...
</Project>

为示例起见,假设我使用配置 Debug_1 SomeModule1.csproj 上工作,该配置使用以下命令在路径D:\ProjectPath1\上构建程序集像这样的结构:

├── ProjectPath1\
│   ├── SomeModule1\...
│   ├── SomeModule2\...
│   ├── SomeModuleX\ (empty folder, is not selected for building in 'Debug_1')

当前情况:

我和我的团队在 Solution.sln 上工作,该项目包含35个项目(请参见上例),该项目具有多个解决方案配置(请参见上例)。每个配置都有自己的输出路径,VS会将文件构建到其中。

问题:

每次我更改活动配置时不构建活动配置,VS都会从其output路径重新创建所有路径,并为当前配置创建空文件夹。此外,它还会为SomeModuleX解决方案配置中未包含的Debug_1创建一个空文件夹

示例:如果我从 Debug_1 更改为其他任何名称,例如 Debug_2 ,并且驱动器上出现一些空文件夹:

├── ProjectPath1\
│   ├── SomeModule1\... (my folders)
│   ├── SomeModule2\... (my folders)
│   ├── SomeModuleX\ (empty folder, is not selected for building in 'Debug_1')
├── ProjectPath2\
│   ├── SomeModule1\ (empty folders)
│   ├── SomeModule2\ (empty folders)
│   ├── SomeModuleX\ (empty folders)

如果我更改为 Debug_X ,驱动器上还会出现一些其他空文件夹:

├── ProjectPath1\
│   ├── SomeModule1\... (my folders)
│   ├── SomeModule2\... (my folders)
│   ├── SomeModuleX\ (empty folder, is not selected for building in 'Debug_1')
├── ProjectPath2\
│   ├── SomeModule1\ (empty folders)
│   ├── SomeModule2\ (empty folders)
│   ├── SomeModuleX\ (empty folders)
├── ProjectPathX\
│   ├── SomeModule2\ (empty folders)
│   ├── SomeModule2\ (empty folders)
│   ├── SomeModuleX\ (empty folders)

如果我删除ProjectPath2ProjectPath3文件夹并在解决方案配置之间进行更改,则该文件夹会再次出现...


我该怎么办?

那么,我该怎么做才能避免这种情况?我可以修改VS中的任何设置吗?我没有运气尝试过IntermediateOutputPath。我会提到,在我们的情况下,我们不能使用Working Directory设置中的Debug吗?

我承认这不是一个止步不前的方法,但有时我感到很疯狂,因为我的驱动器上有一堆空文件夹(等于配置数量)(是的,我知道,OCD)。


长话短说:

如何告诉Visual Studio:“除非我按 Build Rebuild 命令,否则请不要创建<OutputPath>Path</OutputPath>的空文件夹!”


LE:此处对此主题感兴趣的人(link)提交给MS的问题

0 个答案:

没有答案