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

  • Home
  • SEARCH
  • 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 4027894
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:09:12+00:00 2026-05-20T11:09:12+00:00

I have a big VS2010 solution, which contains a bunch of C# projects. One

  • 0

I have a big VS2010 solution, which contains a bunch of C# projects. One of those projects consumes a C++ (native, aka unmanaged) library via P/Invoke. To ensure everything builds correctly, I have included said C++ project in the same solution. Now, this is where the problems start.

In short: MSBuild mysteriously removes some output files, while VS2010 builds correctly.
.

The long story:
Previously (VS2005/2008), I would have utilized the nifty feature called “Project Dependencies”. That’s the thing that allows you to pick which particular projects a given project depends on, so that the environment makes sure to build those first.

VS2010, however, has moved in the direction of MSBuild, and now project dependencies just plain don’t work. They just don’t. (see this question for example)
Now, in order to ensure that my C++ project builds before the one consuming it, I have to “Add a Reference”. So I’ve done that. And everything seems fine.

But then, I go to my command line and fire up MSBuild to build that same solution. And everything builds fine, again. But when I look in the output folder, the C++ project’s output is not there!

The MSBuild console output clearly shows that the C++ project has really been built at some point. And I even inserted some “dir bin\MYPROJNAME.dll” statements as Post-Build steps into some projects to see if the files are there – and they are! Here is a screenshot of the command-line window. Circled in red is the moment of files being there (at the top), and then the moment of files missing (at the bottom).

Another weird thing is that the project, apparently, gets built twice. See the red underline in the screenshot – this is the second message about building that same project (the first message, along with all compiler output, was way up the screen).

It really looks like this second building event is what causes the files to be removed: when I disabled building this project at all (through solution properties), it only got built one time, and the files were there in the end. I could have called this a “solution”, but then it breaks in the Visual Studio itself: the VS just doesn’t build the project.

Another way to fix this is to remove the “Project Reference” from the consuming C# project. Then MSBuild will only build the C++ project once, and the files will be there. But then it breaks in yet another place: changes to the C++ project would not trigger a rebuild of the consuming C# project.

So the question is: how do I make MSBuild not remove the freaking files?

  • 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-20T11:09:13+00:00Added an answer on May 20, 2026 at 11:09 am

    Short (a bit of a hack) answer to the question:

    You had the dir in the PostBuildEvents. If you add an attrib +r it will not remove your files:

    <Exec Command="attrib +r $(TargetPath)"/>
    

    (Where TargetPath should be the dll files…)

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

Sidebar

Related Questions

No related questions found

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.