如何避免Visual Studio 2022将项目配置添加到输出路径

问题描述 投票:0回答:3

there是基于

Microsoft的调试器设置的完整解决方案

单击项目> [项目名称]

visual-studio-2022
3个回答
10
投票

单击项目>编辑项目文件 addto

  1. <PropertyGroup> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <OutputPath>C:\[full directory path]\[name of project]</OutputPath> <PropertyGroup>
  2. 在我的案件中 - 通过Nunit测试项目,它也无济于事。总是创建了
  3. debug
  4. release
文件夹。 我必须在项目文件中进行以下更改: 来自:
<PropertyGroup>
    <TargetFramework>net48</TargetFramework>
    
    <IsPackable>false</IsPackable>
    <BaseOutputPath>bin\</BaseOutputPath>
    <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>

5
投票

<PropertyGroup> <TargetFramework>net48</TargetFramework> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <IsPackable>false</IsPackable> <OutputPath>bin\</OutputPath> <IntermediateOutputPath>obj\</IntermediateOutputPath> </PropertyGroup> 输出路径是一堆MSBUILD属性的串联。 根据您的项目类型,它可以在项目文件中,明确导入的目标文件或通过MSBUILD SDK等隐性导入中发生。 在这些情况下,您应该能够通过明确设置项目文件中的值来覆盖它。

以第三种情况为例(使用Microsoft.net.sdk),在microsoft.net.defaultoutputpaths.targets中,您会发现类似于此的默认值:
    <BaseOutputPath Condition="'$(BaseOutputPath)' == ''">bin\</BaseOutputPath>
    <BaseOutputPath Condition="!HasTrailingSlash('$(BaseOutputPath)')">$(BaseOutputPath)\</BaseOutputPath>
    <OutputPath Condition="'$(OutputPath)' == '' and '$(PlatformName)' == 'AnyCPU'">$(BaseOutputPath)$(Configuration)\</OutputPath>
    <OutputPath Condition="'$(OutputPath)' == '' and '$(PlatformName)' != 'AnyCPU'">$(BaseOutputPath)$(PlatformName)\$(Configuration)\</OutputPath>
    <OutputPath Condition="!HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath>

注意,
$(OutputPath)
基本上是如何将

4
投票
附加到

$(BaseOutputPath)

如果您想始终具有相同的输出路径,则可以在项目文件中设置

<OutputPath>Your\Desired\Path</OutputPath>
。  设置该值后,将根据现在的false条件跳过上面的默认逻辑(
'$(OutputPath)'

不再为空)。

,但是,如果您构建不同的配置而不删除构建之间的输出文件夹的内容,则可能会破坏增量构建。
    
	
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.