If solution is run immediately after rebuilding, files that are copied to output directory are deleted.

  • Thread starter Thread starter SWheaties
  • Start date Start date
S

SWheaties

Guest
Issue: If solution is run immediately after rebuilding, files that are copied to output directory are deleted.
Visual Studio version: Community 2013 Version 12.040629.00 Update 5

Running on Windows 10

My solution is structured like this:
MySolution.Services (library project)
MySolution.Main (startup project - WPF application)

In the services project, there are some files that are marked "Copy to output directory = Copy Always"
When I build I am able to see the files being output to the correct directory.
None of my projects have build events.
All of my projects output to "..\Builds".


The following sequence works correctly (files are not deleted):
Make a random change to a .cs file
Click Start Debugging


The following sequence causes the files in the output directory to be deleted:
Click Build -> Rebuild Solution
Click Start Debugging
Files in output directory are deleted immediately.

I am able to reproduce this issue at will.
I have a breakpoint in Application_Startup. I can see the files are deleted before any of my code runs (BTW I have no code in my application that deletes these files under any condition.):

public partial class App : Application
{

private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.Args.Length > 0 && e.Args[0] == "-debug" && !Debugger.IsAttached)
Debugger.Launch();
int xzzzz = 5555; // breakpoint here. Change this to force rebuild

Continue reading...
 
Back
Top