why building a c# project via console app takes too much time

Answered why building a c# project via console app takes too much time

  • Wednesday, February 15, 2012 10:12 AM
     
      Has Code

    Hello everyone ,

    i am working in a process where we want to automate our project generating / building...

    we have a package written in vs 2008 and a lot of projects written with vs 2008 sdk 1.1 using our package...

    i finally make it via a console application that generates files from our sdk projetcs...

    i am doing it like this...

    first loading all projects in a solution programmatically ...

    then starting from the first project i generate files ...then i have to build first project

    so the second project has a reference to first...so goes like these...

    i can build the first project like this...

    p.StartInfo.RedirectStandardInput = true;

    p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = System.Configuration.ConfigurationManager.AppSettings["devenvPath"];  string newfilePath = projectFilePath.Replace("\\""/");

    p.StartInfo.Arguments = "/rootSuffix Exp /RANU /rebuild Debug  /out  "+projectName+"Error.txt "  + newfilePath  ; p.Start(); p.WaitForExit(); p.Close();

    this works for this scenario ..but i can not catch if any of the skd project is not build and has errors ..

    so i tried below sample code

    ProjectCollection collection = new ProjectCollection();
    Microsoft.Build.Evaluation.Project project = collection.LoadProject(path);
    bool success = project.Build();

    but this takes nearly 30 minitus(or more) to build one of the project...

    can anyone has an idea what is wrong with these code or point me a direction to find a solution...


    thanks...

     

    evgeni

All Replies

  • Friday, February 17, 2012 7:49 AM
    Moderator
     
     

    Hi evgenixristov,
    I have tested it in my computer. But in my computer the VS doesn’t take so much time to build my c# project.
    The following are what I have done:
    1. Create a c# console project named cscontest11, the path is C:\\Users\\[user name]\\Documents\\visual studio 2010\\Projects\\cscontest11\\cscontest11\\cscontest11.csproj
    2. Create a addin , put the following code to my connect.cs file:
    ProjectCollection collection = new ProjectCollection();
    Microsoft.Build.Evaluation.Project project = collection.LoadProject("C:\\Users\\[user name]\\Documents\\visual studio 2010\\Projects\\cscontest11\\cscontest11\\cscontest11.csproj");
    bool success = project.Build();
    3. Then I run my addin. The add-in build quickly.

    I suggest you to try the following workarounds to see whether they are helpful:
    1. If we reboot the operating system to safe mode, do we have the problem? This can help to isolate whether any other applications are interfering with Visual Studio. Note that some features (like IIS) are not available under safe mode. Please check whether this can apply or not. In addition to safe mode, we can also suggest “clean boot”: http://support.microsoft.com/kb/310353.

    2. If we create a new user account, do we have the problem? This can help to isolate user profile corruption related causes.

    3. If we disable Add-ins (e.g. “Tools” | “Add-in Manager”) and run “devenv.exe /safemode”, do we still have the problem? This can eliminate the possibility that third party Add-ins are causing problems.

    4. If we use “devenv.exe /resetsettings”, does it solve the problem? It restores Visual Studio default settings.

    5. If we create a new project, do we have the problem? Sometimes corrupted project settings can cause problems. These are project specific.

    Best regards,
    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us


  • Friday, February 17, 2012 7:54 AM
     
     

    thanks Lucy Liu...

    i will try as soon as possible   and let u know ..

    additionally 

    if i just open the project and rebuild it via ide it takes nearly 2-3 minitues...

    but if i use msbuild from commandline passing the project to build 

    also it takes 30 minutes or much..

    this maybe reach us at a different point...

    iwill try your suggestions but this with msbuild from command line is also odd for me ..

    any suggestions / opinions for this??

    maybe is it something with run as admin privileges ? just a thought..

    thanks..


    evgeni


  • Wednesday, February 22, 2012 8:26 AM
    Moderator
     
     

    Hi evgenixristov,
    Do you have any news about this issue?

     


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

  • Wednesday, February 22, 2012 8:48 AM
     
     Answered

    no if i build with msbuild option from command-line still it completes in 30 minutes...

    but i solved this isue 

    using Dte2 BuildSolution methods.

    thanks ..


    evgeni

    • Marked As Answer by evgenixristov Wednesday, February 22, 2012 8:48 AM
    •