Search code examples
c#dnxdnu

Compile a single C# file using DNX/DNU


Is it possible to compile a single C# file using the new .NET cross-platform toolchain (DNX/DNU) without first making a project.json file?

For example, with Mono you can do:

mcs Program.cs

The mcs command creates Program.exe if it finds a Main method otherwise it creates Program.dll.

I'm trying to build on Mac and Ubuntu using the open source Microsoft tools instead of Mono. I make a ton of tiny little programs for demonstration purposes and I don't want to have to create a project.json file every time.


Solution

  • I dont think that is possible. You would need project.json to build. If you try build Program.cs without project.json through dnu you would get "Unable to locate project.json"

    PATH TO PROJECT>dnu build
    
    Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16231
    
    Unable to locate project.json.
    Total build time elapsed: 00:00:00.0133362
    Total projects built: 1