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

    Question

  • 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
    

    Tuesday, January 19, 2016 2:30 AM

All replies

  • Hi SWheaties,

    According to your description, I create a sample solution that contains a class library project and a WPF project with Visual Studio 2013 on Windows 10. Then I add Class1 and Class2 in my library project, both of them set as Copy Always.

    After I click Start Debugging directly, the Class1 and Class2 files are all in output directory. And then I modify some code in my Class1 and rebuild solution, the files still in the output directory.

    Please create a new solution without any custom code to make sure this problem is occurs with all solution or just this specific project.

    If just this specific project, please delete the .suo file and then try again to check whether still has this problem. If still exist, please create a new solution and then move project files to the new solution one by one to confirm which file causes this issue.

    If for all projects, does this problem occurs when installing or using for a while? If using for a while, please reset all settings for your Visual Studio through menu Tools -> Import and Export settings -> Reset all settings. Then please try repair your Visual Studio.

    If after installing, please check the ActiveLog.xml whether there has any operation information about this issue under the path of %AppData%\Microsoft\VisualStudio\14.0. This file will log all operations when you operate Visual Studio.

    Best Regards,
    Weiwei

    Wednesday, January 20, 2016 5:50 AM
    Moderator
  • I created a different project and I cannot reproduce the problem.  However as stated in my original post I can still reproduce the issue at will in my work project.

    I deleted the .suo file, problem still persists.

    I really do not want to resent my VS settings as I need to use VS right now for development.

    Friday, January 22, 2016 5:32 AM
  • Hi SWheaties,

    Since this problem occurs with the specific project, it is not related to Visual Studio. I suggest you create a new project and then move the project file to the new project one by one. It can help us make sure which file causes this issue.

    >>I really do not want to resent my VS settings as I need to use VS right now for development.

    You can exporting the Visual Studio settings through Tools -> Import and Export settings to backup the settings. After reset all settings to make sure it is not related to the settings, you still can import the settings through Tools -> Import and Export settings again. It won't effect your development.

    Best Regards,
    Weiwei

    Friday, January 22, 2016 9:40 AM
    Moderator
  • >>Since this problem occurs with the specific project, it is not related to Visual Studio.

    Well I don't really understand how you come to this conclusion since a) my project was created by Visual Studio, and b) just because I don't have another project at this moment with the same problem does not in any way allow us to rule out causation.

    Unfortunately I do not have a day to spend troubleshooting this.  I will be glad to send you my project and your team, who is far more capable than I am, will no doubt be able to identify the issue quickly.


    • Edited by SWheaties Friday, January 22, 2016 2:56 PM
    Friday, January 22, 2016 2:55 PM
  • Hi SWheaties,

    >>  I will be glad to send you my project and your team, who is far more capable than I am, will no doubt be able to identify the issue quickly.

    Please upload your project to OneDrive and share the link here. Then I will download it immediately. And then I can try reproduce your problem in my side.

    Best Regards,
    Weiwei

    Monday, January 25, 2016 1:55 AM
    Moderator