Jefe
Jefe

Reputation: 177

MSBuild - how to pass a parameter to an imported project

I have a project file that is using a property $(source) such as :

<ItemGroup>
    <ZipFiles Include="$(Source)\**\*.*" />
</ItemGroup>
<Target Name="Package">
   <Zip Files="@(ZipFiles)" ZipFileName="ZipOutputFullPath" />
</Target>

Now, I'm using this project file in a second project file and I need to copy some zip files into a folder that I construct based on some other parameters and I need to pass in that folder as $(source) to imported project, how can I do this? I'm referencing the imported target like this:

<Target Name="PrepareDropAndPackage" DependsOnTargets="PrepareDrop;Package">
        <Message Text="Finishes preparing drop and packaging." />
</Target>

So basically I need to somehow pass in $(source) to Package target.

Thanks,

Upvotes: 1

Views: 1515

Answers (1)

Ludwo
Ludwo

Reputation: 6173

You need to update $(Source) property before calling the PrepareDropAndPackage target or to change $(Source) property inside that target like this:

<Target Name="PrepareDropAndPackage" DependsOnTargets="PrepareDrop">
    <PropertyGroup>
        <!-- :)) -->
        <Source>C:\Windows<Source>
    </PropertyGroup>
    <CallTarget Targets="Package">
    <Message Text="Finishes preparing drop and packaging." />
</Target>

Upvotes: 1

Related Questions