MSBuild SLN이지만 여전히 별도의 프로젝트 출력을 얻습니까?
-
06-07-2019 - |
문제
일반 SLN 파일이 있고 명령 줄에서 MSBuild로 잘 컴파일하고 있습니다. 나는 이것을한다:
C : slndir> msbuild /p : outdir = c : slnbin
그리고 그것은 c : slnbin_publishedwebsites 에 배포되는 웹 사이트를 제외하고 C : Slnbin에 모든 것을 버립니다.
내가 원하는 것은 Bin Dir에 모든 바이너리를 떨어 뜨릴뿐만 아니라 각 웹 사이트가 얻는 것과 유사하게 자체 "배포 된"폴더가있는 각 실행 가능한 프로그램도 갖는 것입니다.
예를 들어, 다음 프로젝트가있는 경우 : -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)"하위 디어를 만듭니다.
바람직하게는 모든 개별 프로젝트 등을 수정할 필요는 없습니다.
이게 가능해? 쉬운?
해결책
John Saunders가 말했듯이 프로세스를 처리하는 마스터 MSBuild 파일이 필요합니다.
다음은 사용하는 샘플입니다 MSBuild 커뮤니티 작업 : getsolutionprojects 주어진 솔루션에 대한 프로젝트가 제공됩니다
<?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 프로젝트 파일을 작성한 다음 원하는 위치에 모든 솔루션 출력을 복사합니다. 이것은 비주얼 스튜디오 팀 빌드가 어떻게 하는가 (대략)입니다.