I have a short C# script that uses various features of the languages and different .NET libraries:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Text;
using System.Threading;
using Microsoft.Win32.SafeHandles;
The full script can be found here.
I compile it with this command:
%WINDIR%\Microsoft.NET\Framework\v3.5\csc.exe code.cs /debug /nologo
But it turns out that .NET Framework v3.5 is not available on some distributions of Windows by default.
What would be the best way to compile this code so it runs on Windows Vista, 7, 8, 8.1 and Server 2008 without a need to download and install the .NET framework?
I tried looking for
%WINDIR%\Microsoft.NET\Framework\v3.0\csc.exe
binary, but it doesn't exist on my machine.
In your
app.config
file you need to specify the supported runtimes you want your app to support. So if you wanted to support 3.0 or newer you would need to have.You also will need to make sure your project targets only .NET 3.0 in your project settings as that is the version that is bundled with Windows Vista.
If .NET is disabled in add-remove programs there is nothing you can do, you would need to have your user install some version either on their own or install it as part of your deployment (a setup installer or One-Click).