有没有一种方法可以将解决方案构建到一个单独的文件夹中?我有几个项目在这个解决方案中,每个项目都访问应该在当前目录中的配置文件。我只是将每个项目的构建文件移动到一个文件夹中,它仍然可以工作,但是看起来非常不整洁。我想知道是否还有其他方法来完成这项任务。
有没有一种方法可以将解决方案构建到一个单独的文件夹中?我有几个项目在这个解决方案中,每个项目都访问应该在当前目录中的配置文件。我只是将每个项目的构建文件移动到一个文件夹中,它仍然可以工作,但是看起来非常不整洁。我想知道是否还有其他方法来完成这项任务。
在解决方案中的每个项目的设置中(如果我们是关于Visual Studio),您可以设置输出目录。菜单:项目 - > 属性 - > 构建 - > 输出路径。例如,我使用..\ Build \ 将项目构建到解决方案根目录的Build目录中。
Create a single common.props file in solution, that will specify and overwrite output and intermediate paths for a project to a common directory (like "Solution/bin"). Here is a sample *.props file that I found linked in the article:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
<Configuration Condition="$(Configuration) == ''">Debug</Configuration>
<OutputPath>$(SolutionDir)\bin\$(Configuration)\</OutputPath>
<OutDir>$(OutputPath)</OutDir>
<OutDir>$(OutputPath)</OutDir>
<IntermediateOutputPath>
$(SolutionDir)\obj\$(Configuration)\$(MSBuildProjectName)\
</IntermediateOutputPath>
<UseCommonOutputDirectory>False</UseCommonOutputDirectory>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
</Project>
Include this file into every *.csproj that you want to set the common output dirs for, by adding this line (the actual path may differ): <Import Project="..\Common.props" />
Directory.Build.props
来解决这个问题。 - undefined您可以更改项目的“输出路径”,默认情况下是给定项目的bin目录。
右键单击每个项目,从上下文菜单中选择属性
,然后选择生成
选项卡。在输出
部分底部更改输出路径:
。为每个项目设置相同的路径。
我同意您问题下面的评论,您不应该更改它。相反,您可以创建一个后置构建操作(PS脚本),将所有文件从项目的bin目录复制到您指定的目录。
更新:
将此脚本设置为后置构建命令(项目属性->生成事件选项卡->后置构建事件命令行):
xcopy "$(TargetDir)*" "$(SolutionDir)Build" /s /i /Y
对于每个项目: