Get Dotnet Framework version from command line

B

bcastaing

Hi everybody,

I write a VBS script witch uses csc.exe (command line dotnet compiler),
but my problem is to detect what version of Dotnet Framework is
installed on the server to use the good repertory 1.1 or 2.0 (v1.1.4322
or v2.0.50215 ...)
What command line or script can I use to get this information ?

Thanks to all for any advice

Bruno
 
M

Mattias Sjögren

I write a VBS script witch uses csc.exe (command line dotnet compiler),
but my problem is to detect what version of Dotnet Framework is
installed on the server to use the good repertory 1.1 or 2.0 (v1.1.4322
or v2.0.50215 ...)
What command line or script can I use to get this information ?


You can have both installed. If you simply want to use v2 if available
and otherwise fall back on v1.1, can't you simply check if
%WINDIR%\Microosft.NET\Framework\v2.0.50727\csc.exe exists?


Mattias
 
B

bcastaing

Yes I can, but how can I check if a newer version is installed in the
future ?

Bruno
 
D

Damien

Yes I can, but how can I check if a newer version is installed in the
future ?

Bruno
On the other hand, how would you know if the code you're trying to
compile uses deprecated/unsupported features, or features for which
breaking changes have been made, in a later version of the framework.

Your situation is: you *know* (or have good reason to suspect) that
your code compiles with C# 2.0. You *know* (or have good...) that your
code compiles with C# 1.1. Your code may work with C#3.0 beta. Does
your code compile with version 4, with version 5, etc?

I've taken a quick scan through the registry, but there doesn't seem to
be anything obvious. You could try enumerating keys under
HKLM\Software\Microsoft\NET Framework Setup\NDP and getting the latest
version, then looking under the directory you can find through the
InstallRoot value under the HKLM\Software\Microsoft\.NET Framework key.
(Or directly search the directories under that directory for
directories which match the patter vn.n.nnnn)

In either case, you'll be dealing with strings and you'll have to do
careful parsing (if you're really future-proofing) that, for instance,
v10.0 sorts higher then v2.

Good luck!

Damien
 
B

bcastaing

Hi,

The Microsoft.NET registry key seems to be different between version
1.1 or 2.0, so do you the better solution to get the actual version
installed ?
Is it listing %WINDIR%\Microosft.NET\Framework\*. and sort the result
and get the highest value ?
Or WMI fonction ?
Do you know a script to do any working solution ?

Thanks
Bruno


Damien a écrit :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top