Quantcast
Channel: MSBuild forum
Viewing all articles
Browse latest Browse all 2763

issue with msbuild target calling msbuild with another msbuild target

$
0
0
I have a msbuild process, which is split into two sections. The first analyzes nuget packages and creates some files. Since it can only analyze nuget packages after the restore it has be called after "CoreCompile" has happened. The second part should embedd those files in the application as embedded resources and there lies my issue. The embedding part has to happen before the "PrepareForBuild" target, but after "CoreCompile" has happened.
My solution for that was to start another build after the restore has happened.
This looks like the following:

 
<Project><PropertyGroup><GivenDirectory>some directory</GivenDirectory><Variable>false</Variable>    <Variable2>false</Variable2></PropertyGroup>  <Target Name="SomeTarget" AfterTargets="CoreCompile" Condition="'$(Variable)' == 'true'">		<MakeDir Directories="$(GivenDirectory)"/><!--this consoletool generates files in the GivenDirectory--><Exec Command="$(ConsoleTool)" /><!--this calls the msbuild with the other target--><MSBuild Properties="Variable2=true"  Targets="EmbeddFiles" Projects="$(MSBuildProjectFullPath)" />       </Target><Target Name="EmbeddFiles" BeforeTargets="PrepareForBuild" Condition="'$(Variable2)' == 'true'"><ItemGroup><EmbeddedResource Include="GivenDirectory\*.*"/>         </ItemGroup></Target></Project>  



This works fine to the point, that the embedded resources are not added to my application.
I can call it with

    msbuild .\myapp.csproj /t:rebuild /Variable=true

and I can see that both targets are executed the way I wanted them, but somehow the embedded resource is not added.

If I comment the first target out the embeddedresources are added though. What did I do wrong?

I tried to do it like in this thread.

Viewing all articles
Browse latest Browse all 2763

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>