Add new Task, Target, etc., to project file

Apr 16, 2011 at 11:13 PM

Hi,

  My library contains a new msbuild task that needs to be integrated into the user's project. This means adding a UseTask, new Target, modify the CoreCompileDependency property, etc., in an existing project file.

  I saw one other question referencing this on the discussion board here: http://nuget.codeplex.com/discussions/229867. The solutoin was to unload the project, modify the file, and re-load it. Is this still the best option to do this?

  Many thanks!

Developer
Apr 16, 2011 at 11:27 PM

No, you don't have to unload the project. You can use the msbuild APIs to manipulate the project file w/o unloading it. I'll try to whip up a sample.

Apr 17, 2011 at 12:48 AM

Thanks! I'd appreciate an example - or just some pointers. The problem is adding the required "UseTask" and the new targets, and modifing old properties - it looks like one has to mess directly with the XML. If you can point me to the documentation on how to manipulate the Project file via the API's I'm happy to post it as an example once I get it to work.

Jun 17, 2011 at 2:14 AM

Hi again,

  Any updates or a sample that I can look at? :-) I've managed to write code to package up the infrastructure libraries that are needed, and I'm now getting close to trying to do this library - which will need to make these makefile modifications. Any pointers would be a huge help! Thanks again, in advance!

  Cheers, Gordon.

Developer
Jun 17, 2011 at 2:18 AM

Check out this thread http://nuget.codeplex.com/discussions/260409

Jun 17, 2011 at 6:49 PM

Thanks! That looks like the sort of thing I need!