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:
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.
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.