Making DOS / Win 3.11 / Win 9x apps with visual studio

User avatar
Caldor
Posts: 368
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 7 times
Been thanked: 7 times

Making DOS / Win 3.11 / Win 9x apps with visual studio

Unread post by Caldor »

I just came across this. I was asked to make my Visual Studio console apps into a single EXE file and I figured, yeah, that should be possible and would be pretty useful. So I looked into it and to my surprise its only rather recently that it had become possible to do this. Using .Net Core 3.x, which is less than a year old. I think its even less than 2 years old even if you count the beta and it was a feature they added to .Net Core 3, it did not have it at the beginning.

These EXE files are called self-contained EXE files, and they have a trim option, so they contain the .Net Core runtime itself and all the DLLs and such. So I though... does that mean it might even run under DOS or will it still require Windows? I googled and found I was not the only one to have thought about this, someone had already done it and succeeded. Normally these self-contained EXE files would be at least 28MB because they contain everything, and that is even if you use a trimming feature. But he manages to bring a compiled EXE down to 27kb! :o

I can probably not replicate that, but I think I will try just for the fun of it. Here is a link to the article:
https://www.hanselman.com/blog/net-ever ... 11-and-dos
User avatar
Caldor
Posts: 368
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 7 times
Been thanked: 7 times

Re: Making DOS / Win 3.11 / Win 9x apps with visual studio

Unread post by Caldor »

I managed to compile an exe file that is less than 5 mb using some of what was used to make that 8kb app.

I have attached it here, not sure if it can run under DOS because its compiled with x64. I will try testing it when I get home.
Attachments
HelloWorld.7z
Hello World app from Visual Studio
(2.68 MiB) Downloaded 18 times
User avatar
Caldor
Posts: 368
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 7 times
Been thanked: 7 times

Re: Making DOS / Win 3.11 / Win 9x apps with visual studio

Unread post by Caldor »

There is a Twitter thread here, also linked in the article where he runs a C# app in Windows 3.11.
https://twitter.com/MStrehovsky/status/ ... 2352034818
User avatar
jrronimo
Posts: 64
Joined: Sat Jul 04, 2020 6:03 pm
Has thanked: 12 times
Been thanked: 5 times

Re: Making DOS / Win 3.11 / Win 9x apps with visual studio

Unread post by jrronimo »

This is awesome stuff. Thanks for sharing!
User avatar
Caldor
Posts: 368
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 7 times
Been thanked: 7 times

Re: Making DOS / Win 3.11 / Win 9x apps with visual studio

Unread post by Caldor »

If others want to experiment:

Here is the 64 bit program that can be used to run 64bit code in DOS, but it requires a 64 bit CPU.
https://github.com/Baron-von-Riedesel/Dos64-stub

More relevant for AO486 is the HX DOS Extender:
https://github.com/Baron-von-Riedesel/HX/releases

Both are on the same git as the link shows, and I asked him about running 32 bit programs in DOS and his answer was:
"The closest match to dos64stb.bin in 32-bit would be the stub loadpe.bin in HX."
His response is in this git issue thread:
https://github.com/Baron-von-Riedesel/D ... b/issues/3

I have a lot of interesting things I want to try these days though, so not sure when I will get around to trying this. I also got responses on Twitter from the one who got C# code compiled with a custom compiler to run under Windows 3.11 and DOS. He had looked into HX but had not tried it yet. He did get the Dos64-stub working though under DOSBox and he got his snake game to run under DOS that way.
Post Reply