Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3614490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:15:19+00:00 2026-05-18T22:15:19+00:00

I am trying to programmatically add the following Target to my Visual Studio Project

  • 0

I am trying to programmatically add the following Target to my Visual Studio Project File.

<Target Name="PostBuildEvent" Condition="'$(PostBuildEvent)'!=''" DependsOnTargets="$(PostBuildEventDependsOn)">
      <Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" IgnoreExitCode="true" />
</Target>

I am pretty sure that IVsBuildPropertyStorage or IVsBuildPropertyStorage2 will not work because the require a ProjectItem aka a node from the <ItemGroup> element in the project file. What I would like to do is add the above xml outside the <ItemGroup> element.

I am trying to use the Visual Studio SDK to do this and the documentation & examples on doing this exact thing seems to be lacking. As of the time of this post I am unable to find a way of doing this. I would really like to avoid loading up the project file (in this case Test.csproj) as an XDocument or an XmlDocument and adding the Target element node that way. It seems messy and could cause more problems.

As an added bonus I would also like to IgnoreOnExit a single PostBuildEvent element, but I am pretty sure that this is not possible with the PostBuildEvent element

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:15:19+00:00Added an answer on May 18, 2026 at 10:15 pm

    Try using the AddTarget method on the ProjectRootElement class in the Microsoft.Build.Construction namespace. That namespace is used to read and write MSBuild files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add rows in a TableLayout programmatically and I am following
I'm trying to add table rows programmatically following the code here /* Find Tablelayout
When I add a database to a program, Visual Studio automatically creates the following
Trying to programmatically add options to a SELECT drop down in IE Windows Mobile.
I'm trying to programmatically add an Execute SQL task from within a script task
I'm trying to programmatically add dots to a radar screen. The code runs without
I'm trying to add a horizontal LinearLayout programmatically, making sure the second child takes
I am trying to turn add a wifi network programmatically and to connect to
I'm trying to add ASPxGridView to page and bind it to ObjectDataSource programmatically. here
I am trying to add another subview programmatically based on some event (user taps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.