Reputation: 16156
I'm scripting my build process, and I'd like to have a single MSBuild script that clones a repo, then includes properties in a file in that repo to drive the build. The only way I've found to include properties from another file is with the Import
task, which can't reside inside a Target
, so the file it's importing has to exist when MSBuild is initially invoked. Is there any way to run the Import
after a target has run, or another way altogether to get properties out of a file in the middle of a build?
Upvotes: 2
Views: 1370
Reputation: 16156
I decided to make two separate calls to my script in the BAT script that invokes it. The first calls my Clone task, which creates the properties file. The second calls the tasks that require those properties. I made sure the <Import>
task has a conditional requiring the file to exist. I'm still open to a cleaner approach, but this works.
Upvotes: 0
Reputation: 450
You have to call "msbuild" task to run another msbuild process for same project with specific params (path to .props file for example).
<Target Name="Default">
<MSBuild
Projects="$(MSBuildThisFileFullPath)"
Properties="ParamsPath='./ParamsPath/name.props"
Targets="DoSomethingTarget"/>
</Target>
<Import Project=$(ParamsPath) Condition="Exists('$(ParamsPath)')"/>
<Target Name="DoSomethingTarget">
<DoSomeThingTasks/>
</Target>
But Im sure that "the right tool for right the job". Maybe you should look at solutions such as FAKE, PSake, Cake?
Upvotes: 2