Build project by code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tiësto

    Build project by code

    Hi again, here goes the same question once more, but this time shorter and
    simpler:

    Is there any way to compile a project (a solution file, properly talking)
    from another application?
    Any object model, class method or any framework component to do this?

    thanks in advance.


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Build project by code

    Tiësto,

    Pre-.NET 2.0, there really isn't. You could automate an instance of
    VS.NET to do this, but that's a rather heavy solution. There is also NAnt,
    I believe, which you could use, but you would have to call out to it (create
    a new process) in .NET, and there isn't a direct mapping from the project
    files in NAnt and C# project files in .NET.

    In .NET 2.0, there is MSBUILD, the build engine which VS.NET uses for
    building applications. This is accessible from a command line utility as
    well as in code through .NET classes. The project files for C# used by
    VS.NET 2005 are actually MSBUILD files, with specific logic for C#.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Tiësto" <a@a.com> wrote in message
    news:%23vBpII5a FHA.1360@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > Hi again, here goes the same question once more, but this time shorter and
    > simpler:
    >
    > Is there any way to compile a project (a solution file, properly talking)
    > from another application?
    > Any object model, class method or any framework component to do this?
    >
    > thanks in advance.
    >[/color]


    Comment

    • Tiësto

      #3
      Re: Build project by code

      Nicholas:

      I've found this, which is all I need by now...



      As you mentioned, I create a process, start it, and wait until it finishes.
      In the meanwhile I can show some message to the user indicating the process
      is taking place. When done, I can query the Process.ExitCod e to know if it's
      finished ok. I could read the log txt file as well.

      I still have to figure out how to analize the possible compilation errors in
      order to show the user which problem had place. But I guess I can parse the
      result text file.

      Additionally, I understand that the application in charge of it needs its
      host machine to have VS installed, which in my case, it's no problem so far.

      I've also seen that there is a Microsoft.CShar p.Compiler class, but it
      processes individual .cs files, which seems bothering for me since I have
      the csproj file already created.

      Thanks your for replying...
      *************** *************** *************** **

      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:OCfsZO5aFH A.2860@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Tiësto,
      >
      > Pre-.NET 2.0, there really isn't. You could automate an instance of
      > VS.NET to do this, but that's a rather heavy solution. There is also
      > NAnt, I believe, which you could use, but you would have to call out to it
      > (create a new process) in .NET, and there isn't a direct mapping from the
      > project files in NAnt and C# project files in .NET.
      >
      > In .NET 2.0, there is MSBUILD, the build engine which VS.NET uses for
      > building applications. This is accessible from a command line utility as
      > well as in code through .NET classes. The project files for C# used by
      > VS.NET 2005 are actually MSBUILD files, with specific logic for C#.
      >
      > Hope this helps.
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      > "Tiësto" <a@a.com> wrote in message
      > news:%23vBpII5a FHA.1360@TK2MSF TNGP10.phx.gbl. ..[color=green]
      >> Hi again, here goes the same question once more, but this time shorter
      >> and simpler:
      >>
      >> Is there any way to compile a project (a solution file, properly talking)
      >> from another application?
      >> Any object model, class method or any framework component to do this?
      >>
      >> thanks in advance.
      >>[/color]
      >
      >[/color]


      Comment

      Working...