Compile a project from code, or explanations about CodeDom...
-
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
-
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
-
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)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!
-
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!
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) -
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) -
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!
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) -
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) -
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
Compiling Source File Dynamically[^]
Giorgi Dalakishvili #region signature my articles #endregion
-
Compiling Source File Dynamically[^]
Giorgi Dalakishvili #region signature my articles #endregion
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?
-
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?
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
-
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
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
-
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
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
-
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
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
-
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
You are welcome :)
Giorgi Dalakishvili #region signature my articles #endregion