msbuild SLN仍然获得单独的项目输出吗? [英] msbuild SLN and still get separate project outputs?

查看:72
本文介绍了msbuild SLN仍然获得单独的项目输出吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个普通的SLN文件,并且正在使用msbuild从命令行对其进行编译.我这样做:

I have a normal SLN file, and I'm compiling it fine with msbuild from the command line. I do this:

C:\ slndir> msbuild/p:OutDir = C:\ slnbin \

C:\slndir> msbuild /p:OutDir=C:\slnbin\

它会将所有内容转储到C:\ slnbin中,但网站已部署到C:\ slnbin_PublishedWebsites \.

And it dumps everything into C:\slnbin, except for websites, which get deployed to C:\slnbin_PublishedWebsites\.

我想要的不仅是将所有二进制文件都放入bin目录中,还要使每个可执行程序都有其自己的"deployed"文件夹,类似于每个网站获得的文件夹.

What I would like is to not only have all the binaries dropped in the bin dir, but also have each executeable program have it's own "deployed" folder, similar to what each website gets.

例如,如果我有以下项目: - 常见的 -Lib1 -服务1 -Lib2 -Service2

So, for example, If I have the following projects: - Common - Lib1 - Service1 - Lib2 - Service2

我想得到:

  C:\slnbin\ // Everything
  C:\slbin\Deploy\Service1 // Common, Lib1, Service1
  C:\slbin\Deploy\Service2 // Common, Lib2, Service2

我尝试做类似"msbuild/p:OutDir = C:\ slnbin \ $(ProjectName)"的操作,但是它只是将其视为文字并创建了一个实际的"$(ProjectName)"子目录.

I tried doing stuff like "msbuild /p:OutDir=C:\slnbin\$(ProjectName)", but it just treats it as a literal and creates an actual "$(ProjectName)" subdir.

最好,我不必修改每个单独的项目,依此类推.

Preferrably, I would not have to modify every individual project and so on.

这可能吗?容易吗?

推荐答案

就像约翰·桑德斯(John Saunders)所说的那样,您需要有一个主MSBuild文件来处理该过程.

Like John Saunders said, you need to have a master MSBuild file that handles the process.

以下是使用 MSBuild社区任务的示例: GetSolutionProjects 对于给定的解决方案

Here is a sample using MSBuild Community Tasks : GetSolutionProjects that gets the projects for a given solution

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Package">

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

  <!-- Specify here, the solution you want to compile-->
  <ItemGroup>
    <Solution Include="C:\slndir\solution.sln"/>
  </ItemGroup>

  <PropertyGroup>
    <Platform>AnyCPU</Platform>
    <Configuration>Debug</Configuration>

    <!-- Your deployment directory -->
    <DeployDir>C:\slbin\Deploy</DeployDir>
  </PropertyGroup>

  <!-- Gets the projects composing the specified solution -->
  <Target Name="GetProjectsFromSolution">
    <GetSolutionProjects Solution="%(Solution.Fullpath)">
      <Output ItemName="ProjectFiles" TaskParameter="Output"/>
    </GetSolutionProjects>
  </Target>

  <Target Name="CompileProject" DependsOnTargets="GetProjectsFromSolution">
    <!-- 
      Foreach project files
        Call MSBuild Build Target specifying the outputDir with the project filename.
    -->
    <MSBuild Projects="%(ProjectFiles.Fullpath)"
             Properties="Platform=$(Platform);
             Configuration=$(Configuration);
             OutDir=$(DeployDir)\%(ProjectFiles.Filename)\"
             Targets="Build">
    </MSBuild>
  </Target>
</Project>

这篇关于msbuild SLN仍然获得单独的项目输出吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆