Compile a C# source code file Without Building in IDE?

  • Thread starter Thread starter Peter van der Goes
  • Start date Start date
P

Peter van der Goes

I'll guess this has been addressed many times, but my finding skills (Google
Groups, etc) seem to have failed me (not unheard of).
Using VS.NET 2003 Pro, I have a multi file project consisting of several
class definitions, each in its own file) from which I wish to instantiate
objects and test the classes in a simple console application with Main(),
contained in a separate file. As long as the file with Main() is in the
project, all is well and I can build/rebuild the project, thus recompiling
the code in all files as needed.
Now, I wish to remove with Main() and just recompile the other files
selectively as needed. When I do that, C# immediately complains that there
is no entry point. So, from C++ experience, I tried adding the Compile
button to the Build toolbar. No go, as the button appears, but is inactive.
I would like to be able to make these classes available to students without
revealing the source code, sort of like giving C++ developers the .h file,
but not the implementing companion .cpp.
So, the question is: is there a way to just compile C# from within the IDE,
or must I resort to using the command line for this activity? Once
accomplished, how do I expose the interface only? Further, is it possible
that what I want to do is inappropriate to the C# development model?

--
**********************************************************************
** All opinions are mine alone.Do not attribute elsewhere!
**********************************************************************
** Peter van der Goes, Professor, Computers & Information Technology
** Rose State College
*********************** Contact ************************************
** Office e-mail: (e-mail address removed)
** Home e-mail: (e-mail address removed)
** Web Page: http://www.rose.edu/Faculty/pvan/index.htm
**********************************************************************
 
Peter van der Goes said:
I'll guess this has been addressed many times, but my finding skills (Google
Groups, etc) seem to have failed me (not unheard of).
Using VS.NET 2003 Pro, I have a multi file project consisting of several
class definitions, each in its own file) from which I wish to instantiate
objects and test the classes in a simple console application with Main(),
contained in a separate file. As long as the file with Main() is in the
project, all is well and I can build/rebuild the project, thus recompiling
the code in all files as needed.
Now, I wish to remove with Main() and just recompile the other files
selectively as needed. When I do that, C# immediately complains that there
is no entry point. So, from C++ experience, I tried adding the Compile
button to the Build toolbar. No go, as the button appears, but is inactive.
I would like to be able to make these classes available to students without
revealing the source code, sort of like giving C++ developers the .h file,
but not the implementing companion .cpp.
So, the question is: is there a way to just compile C# from within the IDE,
or must I resort to using the command line for this activity? Once
accomplished, how do I expose the interface only? Further, is it possible
that what I want to do is inappropriate to the C# development model?

Compiling just *parts* of a project does sound somewhat odd. If you
just want to compile a project which doesn't have a Main, and give it
to them as a DLL, you just need to change the project type to a Class
Library.
 
Jon Skeet said:
Compiling just *parts* of a project does sound somewhat odd. If you
just want to compile a project which doesn't have a Main, and give it
to them as a DLL, you just need to change the project type to a Class
Library.

Thanks very much, Arild and Jon. I appreciate the helpful answer sans
sarcasm :-)
Obviously, I should have seen that.
 
Back
Top