Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Compile a project from code, or explanations about CodeDom...

Compile a project from code, or explanations about CodeDom...

Scheduled Pinned Locked Moved C#
helptutorialquestion
14 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kontax
    wrote on last edited by
    #1

    Hi everyone, I have a big problem I can't manage to solve.. This is the explanation: I have two windows form projects. The first one is needed only to output a .cs file, with inside parameters given by the user. And thi is ok. The generated .cs file should be the code file for the other windows form application. And this is also ok. Now I need to compile the project from the first application, and this is what's missing. Any advice? I tried to use the CodeDom, but I just could manage to create a console application,like in the example given in the msnd documentation. Thanks Bye Gabri

    L G 2 Replies Last reply
    0
    • K kontax

      Hi everyone, I have a big problem I can't manage to solve.. This is the explanation: I have two windows form projects. The first one is needed only to output a .cs file, with inside parameters given by the user. And thi is ok. The generated .cs file should be the code file for the other windows form application. And this is also ok. Now I need to compile the project from the first application, and this is what's missing. Any advice? I tried to use the CodeDom, but I just could manage to create a console application,like in the example given in the msnd documentation. Thanks Bye Gabri

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Now what is the problem you are experiencing? Cant you just add an entry in the second project for the generated file?

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)

      K 1 Reply Last reply
      0
      • L leppie

        Now what is the problem you are experiencing? Cant you just add an entry in the second project for the generated file?

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)

        K Offline
        K Offline
        kontax
        wrote on last edited by
        #3

        Hmm I think I explained it bad, or perhaps I couldn't understand your answer.. I try to explain better the problem: First application generates the .cs file and puts it in the second application folder. First application in still running. Now First application should compile the second application in an .exe file. I just can't understand how to do this. With CodeDom I understood how to create a simple console application, but it isn't what i need, my second application should be a windows form application. If your answer was right, can you explain it better to me? Thanks anyway for the answer!

        L 1 Reply Last reply
        0
        • K kontax

          Hmm I think I explained it bad, or perhaps I couldn't understand your answer.. I try to explain better the problem: First application generates the .cs file and puts it in the second application folder. First application in still running. Now First application should compile the second application in an .exe file. I just can't understand how to do this. With CodeDom I understood how to create a simple console application, but it isn't what i need, my second application should be a windows form application. If your answer was right, can you explain it better to me? Thanks anyway for the answer!

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Ok, I understand a bit better. The best choice IMO is to utilize MSBuild. The first application will call MSBuild on the seconds project file after the first project has generated the C# file. You can call MSBuild either via code (hard) or just as a process (easy).

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 alpha 4a out now (29 May 2008)

          K 1 Reply Last reply
          0
          • L leppie

            Ok, I understand a bit better. The best choice IMO is to utilize MSBuild. The first application will call MSBuild on the seconds project file after the first project has generated the C# file. You can call MSBuild either via code (hard) or just as a process (easy).

            xacc.ide - now with TabsToSpaces support
            IronScheme - 1.0 alpha 4a out now (29 May 2008)

            K Offline
            K Offline
            kontax
            wrote on last edited by
            #5

            Yes, it seems to be the solution! Ok, last two questions.. 1)Have you ever used it? A little little explanation of how it works is possible? 2)What do you mean with "via code (hard) or just as a process (easy)." Thanks again!

            L 1 Reply Last reply
            0
            • K kontax

              Yes, it seems to be the solution! Ok, last two questions.. 1)Have you ever used it? A little little explanation of how it works is possible? 2)What do you mean with "via code (hard) or just as a process (easy)." Thanks again!

              L Offline
              L Offline
              leppie
              wrote on last edited by
              #6

              kontax wrote:

              1)Have you ever used it? A little little explanation of how it works is possible?

              Yes. Just type in 'msbuild /?' to get all the options. There are MSDN docs too, Google for a few tutorials to get the hang of it. VS uses it internally.

              kontax wrote:

              2)What do you mean with "via code (hard) or just as a process (easy)."

              via code: Reference the MSBuild assembly (not sure about the name now), and call the method via code. via process: Process.Create("msbuild ...")

              xacc.ide - now with TabsToSpaces support
              IronScheme - 1.0 alpha 4a out now (29 May 2008)

              K 1 Reply Last reply
              0
              • L leppie

                kontax wrote:

                1)Have you ever used it? A little little explanation of how it works is possible?

                Yes. Just type in 'msbuild /?' to get all the options. There are MSDN docs too, Google for a few tutorials to get the hang of it. VS uses it internally.

                kontax wrote:

                2)What do you mean with "via code (hard) or just as a process (easy)."

                via code: Reference the MSBuild assembly (not sure about the name now), and call the method via code. via process: Process.Create("msbuild ...")

                xacc.ide - now with TabsToSpaces support
                IronScheme - 1.0 alpha 4a out now (29 May 2008)

                K Offline
                K Offline
                kontax
                wrote on last edited by
                #7

                Ok Thanks again!

                1 Reply Last reply
                0
                • K kontax

                  Hi everyone, I have a big problem I can't manage to solve.. This is the explanation: I have two windows form projects. The first one is needed only to output a .cs file, with inside parameters given by the user. And thi is ok. The generated .cs file should be the code file for the other windows form application. And this is also ok. Now I need to compile the project from the first application, and this is what's missing. Any advice? I tried to use the CodeDom, but I just could manage to create a console application,like in the example given in the msnd documentation. Thanks Bye Gabri

                  G Offline
                  G Offline
                  Giorgi Dalakishvili
                  wrote on last edited by
                  #8

                  Compiling Source File Dynamically[^]

                  Giorgi Dalakishvili #region signature my articles #endregion

                  K 1 Reply Last reply
                  0
                  • G Giorgi Dalakishvili

                    Compiling Source File Dynamically[^]

                    Giorgi Dalakishvili #region signature my articles #endregion

                    K Offline
                    K Offline
                    kontax
                    wrote on last edited by
                    #9

                    Yes,i tried that way. But I understood only how to compile a source files. I could just compile from a .cs file to a .exe file. I need to compile a project made from a form and its .cs file together in an executable file. Is there a workaround to do this with CodeDom or CSharpProvider?

                    G 1 Reply Last reply
                    0
                    • K kontax

                      Yes,i tried that way. But I understood only how to compile a source files. I could just compile from a .cs file to a .exe file. I need to compile a project made from a form and its .cs file together in an executable file. Is there a workaround to do this with CodeDom or CSharpProvider?

                      G Offline
                      G Offline
                      Giorgi Dalakishvili
                      wrote on last edited by
                      #10

                      If you put your form's designer generated code and the cs file into one file then you can compile it using CSharpProvider, but you can't compile a project.

                      Giorgi Dalakishvili #region signature my articles #endregion

                      K 1 Reply Last reply
                      0
                      • G Giorgi Dalakishvili

                        If you put your form's designer generated code and the cs file into one file then you can compile it using CSharpProvider, but you can't compile a project.

                        Giorgi Dalakishvili #region signature my articles #endregion

                        K Offline
                        K Offline
                        kontax
                        wrote on last edited by
                        #11

                        I just tried but I got a lot of errors.. I used this sample code: http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.aspx. Most of the errors are about missing assemblies(I didnt' use custom assemblies, only from the framewrok)..Obviusly when I try to compile from the project, there are no errors.. Any advidce? Thanks anyway

                        G 1 Reply Last reply
                        0
                        • K kontax

                          I just tried but I got a lot of errors.. I used this sample code: http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.aspx. Most of the errors are about missing assemblies(I didnt' use custom assemblies, only from the framewrok)..Obviusly when I try to compile from the project, there are no errors.. Any advidce? Thanks anyway

                          G Offline
                          G Offline
                          Giorgi Dalakishvili
                          wrote on last edited by
                          #12

                          With CSharpProvider you have to programmatically add referenced assemblies. Did you have a look at the link I provided?

                          Giorgi Dalakishvili #region signature my articles #endregion

                          K 1 Reply Last reply
                          0
                          • G Giorgi Dalakishvili

                            With CSharpProvider you have to programmatically add referenced assemblies. Did you have a look at the link I provided?

                            Giorgi Dalakishvili #region signature my articles #endregion

                            K Offline
                            K Offline
                            kontax
                            wrote on last edited by
                            #13

                            Yes I did.. and it's a really good article!(I also didn't know how to drag files..) I'd seen you used the CSharpProvider, i just thought it could be possible also with CodeDom like i did, cause I used it to compile other kind of .cs files. Ok, I'll switch to the CSharpProvider.. THANKS for everything! bye

                            G 1 Reply Last reply
                            0
                            • K kontax

                              Yes I did.. and it's a really good article!(I also didn't know how to drag files..) I'd seen you used the CSharpProvider, i just thought it could be possible also with CodeDom like i did, cause I used it to compile other kind of .cs files. Ok, I'll switch to the CSharpProvider.. THANKS for everything! bye

                              G Offline
                              G Offline
                              Giorgi Dalakishvili
                              wrote on last edited by
                              #14

                              You are welcome :)

                              Giorgi Dalakishvili #region signature my articles #endregion

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups