Reputation:
How can I programmatically (C#) obtain the version of Visual Studio my application was built with?
Upvotes: 3
Views: 413
Reputation: 5297
I can categorically tell you that for a standard assembly, this is not possible. There is nothing that visual studio embeds in any of the metadata that gives you this information. So unfortunately this is not possible - the best you can do is make an educated guess (e.g. if it targets .NET framework 4.0 then it's probably Visual Studio 10). However, it's not just Visual Studio that can build managed code.
What's the reason behind this? If we understand the core task there may be alternatives.
Upvotes: 0
Reputation: 421
You could add a new appSettings key in your web.config, and then manually update the value as developers take over in the future.
The .csproj file contains meta data that you could query from.
Upvotes: 1
Reputation: 1000
You can build your application with other tools such as MSBuild. In some larger working environments the F5 build and run is disabled and have much more complext build systems.
I don't think it is possible to tell which version other than the .net version which is requiured.
Upvotes: 0
Reputation: 7541
System.Environment.Version
gives you the .NET version you are using...I know it's not what you asked for, but something interesting.
Upvotes: 0
Reputation: 74270
Looking at the compiled assembly there is no way you can differentiate between one built with a command line csc or built with visual studio.
Upvotes: 6