외부 프로젝트 파일에서 속성을 정의하면 각 프로젝트에서 속성 설정을 가져올 수 있습니다.
다음은 현재 작업중인 orders.properties라는 매우 간단한 속성 파일입니다.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- always include the root properties -->
<Import Project="$(root)\root.properties.proj"/>
<PropertyGroup>
<!-- Version numbers/names for this branch -->
<orders_ver_major>99</orders_ver_major>
<orders_ver_minor>0</orders_ver_minor>
<orders_ver_release>0</orders_ver_release>
<orders_ver>$(orders_ver_major).$(orders_ver_minor).$(orders_ver_release)</orders_ver>
<orders_ver_db>$(orders_ver_major)_$(orders_ver_minor)_$(orders_ver_release)</orders_ver_db>
<!-- setup folders specific to the orders project -->
<orders_database>$(orders_root)\btq.orders.database</orders_database>
<!--
Setup order database default properties, can be overriden if passed in when called from
the command line or from other build scripts.
-->
<orders_force_create Condition="'$(orders_force_create)' == ''">false</orders_force_create>
<orders_db_server Condition="'$(orders_db_server)' == ''" >.\sqlexpress</orders_db_server>
<orders_db_username Condition="'$(orders_db_username)' == ''" >yyyyyyyy</orders_db_username>
<orders_db_password Condition="'$(orders_db_password)' == ''" >xxxxxx</orders_db_password>
<orders_db_name Condition="'$(orders_db_name)' == ''" >$(COMPUTERNAME)_btq_orders_v$(orders_ver_db)</orders_db_name>
</PropertyGroup>
</Project>
주 빌드 프로젝트에서 orders.build.proj 파일과 필요한 모든 하위 프로젝트의 주문 속성을 가져옵니다.
다음은 기본 빌드 파일의 초기 섹션입니다.
<Project DefaultTargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Always setup the path to the root and also the orders root folder.
We then include the orders properties, which includes the root properties
For this project the orders folder is in the same folder as this build file
so can just reference the ms build project directory property as the orders_root.
-->
<PropertyGroup>
<root>$(MSBuildProjectDirectory)\..\..</root>
<orders_root>$(MSBuildProjectDirectory)</orders_root>
</PropertyGroup>
<!--
Once we have the roots configured we can now include all the standard properties,
this also includes the root.properties also.
-->
<Import Project="$(orders_root)\orders.properties.proj"/>
희망 사항. 질문에 대한 답변입니다.
친절 감사 노엘
1 브릴리언트! 양방향 종속성을 방지하기 위해 속성을 별도의 파일에 저장하는 것이 좋습니다. 많은 감사합니다! –
이러한 전역 속성을 설정할 수있는 작업을 호출하는 방법이 있습니까? 예 : buildDate라는 속성을 만든 다음 buildDate를
속성 함수를 통해 빌드 대상 내의 모든 속성에 항상 타임 스탬프를 넣을 수 있습니다. 예를 들어, 대상의 PropertyGroup 섹션에서 $ (DateTime.Now) MyTimestamp>로 설정하십시오. http://msdn.microsoft.com/en-us/library/dd633440.aspx를 참조하십시오. –
d3r3kk