msbuild SLN and still get separate project outputs?

前端 未结 2 933
借酒劲吻你
借酒劲吻你 2021-02-05 21:41

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\\

And it dumps every

相关标签:
2条回答
  • 2021-02-05 22:13

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

    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>
    
    0 讨论(0)
  • 2021-02-05 22:33

    You'll have to do this "by hand". Create a master MSBUILD project file that builds the solution, then copies all the solution outputs where it wants them. This is (roughly) how Visual Studio Team Build does it.

    0 讨论(0)
提交回复
热议问题