Skip to content

jomots/csharpcmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

csharpcmd

C# cmd file header

Allows to create Windows .cmd from any runnable c# file. When started, will compile , run and then delete executable file.

Very similar thing could be found on internet - it is there for a pretty long time. Advantage of this one is that it looks for most recent csc compiler in registry, whichever it is, instead of going through list of predefined .NET versions.

Example:
anyreasonablename.cmd

/*
@echo off && cls
set NetReg=reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP" /s
for /f "tokens=2,3*" %%i in ('%NetReg% ^| find "InstallPath"')  do Set csc=%%j
if "%csc%" == ""   (
echo No .NET path found.  Compilation Failed.
goto:eof )

set csc="%_NetInstallPath:~0,-1%\csc.exe"
%csc% /nologo /out:"%~0.exe" %0
"%~0.exe" %1
del "%~0.exe"
exit
*/
using System;

namespace Test
{
  class TestClass
  {
    static void Main(string[] args)
    {
      if (args.Length == 1)
        Console.WriteLine("Done.Xo-xo-xo.");
      else
        Console.WriteLine("Done.Run it again.");
    }
  }
}

About

C# cmd header

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors