Reputation: 3009
I want to have something like:
let COMP_NAME = %some_type_of_flag%
So that at compile time, this is changed to
let COMP_NAME = "MyComputerName"
Edit: I see that my question was incomplete. This is a silverlight application. It appears Environment does not have MachineName. I'm using f#.
Edit: I'm using Visual Studio 2010 and the code behind is in f# (Don't ask). The reason I want to do this is that in our development environment, we run the server on the local machine. When someone checks out the code, they have to enter their machine name in the code. Using 'localhost' works when you access the app locally, obviously this won't work when accessing it from another machine. So the solution must be at build time.
I'm not sure what compiler I'm using, whatever the default f# compiler is in VS2010.
Upvotes: 2
Views: 2469
Reputation: 3009
I've found the solution I'm looking for, and it's not getting the computer name at compile time, it's getting the source host at runtime.
let host = Application.Current.Host.Source.Host
let uri = new Uri("https://" + host)
Upvotes: -1
Reputation: 241711
I don't know of a way to do it simpler than the following. You want to set up a prebuild step (Project -> Properties -> Build Events -> Pre-build event command line).
Here, you can set up a program that will scream through your source files and replace some specific token (%MachineName%
) with the value of Environment.MachineName
. This is a program that you will have to write separately.
Upvotes: 3