1

Is there a way that I can compile an application outside of visual studios from another c# application?

I have an application the requires a unique id coded into a device, I want that build coded for just that device, so instead of me having to change the hardcored ID, build, place on device. I would like to write another application that pulls the devices ID, modifies the needed .cs files then builds the project in release and copied it to the device.

Can this be done?

Also I do have post build code that runs if that matters in the process.

Tsukasa
  • 6,342
  • 16
  • 64
  • 96
  • Make your second project compile as if from the command line, see this http://stackoverflow.com/questions/553143/compiling-executing-a-c-sharp-source-file-in-command-prompt – Julián Urbano Dec 19 '13 at 04:16
  • 1
    Use an app.config to store the unique ID instead of hard-coding it into the application? – Daniel Mann Dec 19 '13 at 04:16

1 Answers1

3

You can use either MSBUILD or CSC. MSBuild, which as you mentioned, does use your project and solution files. CSC will compile specific files, or all files in a specific directory tree.

MSBuild is the easiest way to go. For instance:

msbuild /property:Configuration=Release MyFile.vbproj

You should also look at automating your builds with NAnt and/or CruiseControl.net.

Also, here is an example on how to compile your code without visual studio using CSC. http://blog.slickedit.com/?p=163

Also take a look at this stuff

How can I compile and run c# program without using visual studio?

Community
  • 1
  • 1
Nidhish Krishnan
  • 20,593
  • 6
  • 63
  • 76
  • Looks like this will do what I need. I don't think I can automate the build all on it's own because it requires me to plug in a new device for every build. Each build is locked to just that device to help prevent it from being duplicated. – Tsukasa Dec 19 '13 at 04:29