Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild Task from .csproj File

Tags:

c#

msbuild

I Am trying to add a Post Build MSBuild event to my csproj to do this i am trying to call an MSBuild task from inside the Afterbuild target in the.csproj file

  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.-->
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
    <Message Text="Copying Files" />
    <MSBuild Projects="post.build" 
        Targets="Copy"
        ContinueOnError="false" />
  </Target>

This is then the post.build file.

 <Project DefaultTargets="Copy"
 xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <Target Name="Copy">
     <Message Text="Copying Files inside COPY" />
     <CallTarget Targets="CopyToProfile"/>   </Target>
 </project>

It seems that the csproj cannot call the MSbuild task, can anyone suggest what might be going wrong here. I get the error

error MSB4057: The target "Copy" does not exist in the project.

like image 630
Bluephlame Avatar asked Dec 15 '25 20:12

Bluephlame


1 Answers

So What I eventually got working was.

I did as Martin Suggested and

<Import Project="post.build"/>

However the MSBuild Task still did not function as planned. So I ended up using the

<CallTarget Targets="copy"/>

To Call across the files. This sounds like it is a limitation in VS2008 and is fixed in VS2010.

like image 100
Bluephlame Avatar answered Dec 17 '25 12:12

Bluephlame



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!