Skip to content

Commit

Permalink
v2.0.0.0
Browse files Browse the repository at this point in the history
(Why does Microsoft have three periods for versions?)
Major refactor of the entire project. Ported the C# code to C++
and also made some other improvements such as removing the
dependency on Visual Studio and MSBuild. The C# stuff currently
uses Makefiles, Nuget, and the Roslyn C# compilers.
  • Loading branch information
falfiya committed Jan 22, 2020
1 parent 2863639 commit 113a4c6
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 172 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.vscode/
/bin/
/cs/bin/
/cs/obj/
/cs/*.exe
/cxx/*.res
/cxx/*.exe
6 changes: 0 additions & 6 deletions App.config

This file was deleted.

33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
_ := dotnetfx35installer.
clr := cs\clr.exe
x64 := cxx\x64.exe
bclr := bin\$(_)clr.exe
bx64 := bin\$(_)x64.exe

cp = copy /v /y /b

all: $(bclr) $(bx64)

rebuild: clean all

bin:
mkdir bin

$(bclr): $(clr) bin
$(cp) $< $@

$(bx64): $(x64) bin
$(cp) $< $@

$(clr):
make -C cs

$(x64):
make -C cxx

clean:
rd /s /q bin || rem
make -C cs clean
make -C cxx clean

.PHONY: all clean
17 changes: 0 additions & 17 deletions app.manifest

This file was deleted.

Binary file removed cs/.clr.exe
Binary file not shown.
2 changes: 0 additions & 2 deletions cs/.gitignore

This file was deleted.

6 changes: 2 additions & 4 deletions cs/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@

[assembly: ComVisible(false)]

[assembly: Guid("709fa7fe-1b9a-4839-8612-e457b6734ef6")]

[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
58 changes: 34 additions & 24 deletions cs/Main.cs
Original file line number Diff line number Diff line change
@@ -1,48 +1,58 @@
using System;
using System.IO;
using System.Reflection;
using System.Diagnostics;

class Program {
using static System.Console;
class _ {
static string[] files = {
"microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab",
"Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~en-US~.cab"
};

static void Main(string[] _) {
Console.Title = "dotnetfx35installer";
string outdir = Path.GetTempPath() + @"dotnetfx35installer\";
Console.WriteLine("Writing temporary installation files to " + outdir);
Console.Write("Does this look correct? Press 'y' continue: ");
var confirm = Console.ReadKey().KeyChar;
Console.Clear();
if (confirm != 'y') {
Title = "dotnetfx35installer.clr";

var outdir = Path.GetTempPath() + @"dotnetfx35installer\";
Write(
$"Writing temporary files to {outdir}\n"
+ "\nDoes this look correct? Press 'y' continue: "
);
if (ReadKey().KeyChar != 'y') {
return;
}
Clear();

Title = "Installing...";

if (Directory.Exists(outdir)) {
Directory.Delete(outdir, true);
}

Directory.CreateDirectory(outdir);

var assembly = Assembly.GetExecutingAssembly();
foreach (var filename in files) {
var stream = assembly.GetManifestResourceStream($"dotnetfx35installer.{filename}");
var output = File.Open(outdir + filename, FileMode.CreateNew);
stream.CopyTo(output);
stream.Dispose();
output.Dispose();
WriteLine("\nGetting resources:");
var names = assembly.GetManifestResourceNames();
for (var i = 0; i < names.Length; ++i) {
var name = names[i];
WriteLine($"{i}: {name}");
var res = assembly.GetManifestResourceStream(name);
var file = File.Open(outdir + name, FileMode.CreateNew);
res.CopyTo(file);
res.Dispose();
file.Dispose();
WriteLine($"{i}: Done");
}

var dism = @"C:\Windows\System32\dism.exe";
var args = $"/Online /Enable-Feature /FeatureName:NetFX3 /All /LimitAccess /Source:{outdir}";
Console.WriteLine("Running DISM:");
Console.WriteLine($"{dism} {args}");
WriteLine($"{dism} {args}");
WriteLine("Please be patient!");
Process.Start(dism, args).WaitForExit();
Console.WriteLine("\nFinished... probably...?");
Console.Title = "yay?";
Console.WriteLine($"Removing {outdir}");

Write($"Finished install\nCleaning Up...\n");
Directory.Delete(outdir, true);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();

Title = "Press any key to exit...";
WriteLine("Press any key to exit...");
ReadKey();
}
}
25 changes: 20 additions & 5 deletions cs/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
include ../vars.mk

outfile := clr.exe

csc := $(shell node where_csc.js)
entry := Main.cs
others := AssemblyInfo.cs
outfile := .clr.exe
args := \
/target:exe \
/win32manifest:$(manifest) \
/resource:$(G11N) \
/resource:$(L10N) \
/optimize+ \
/warnaserror+

$(outfile): *.cs $(G11N) $(L10N)
$(csc) *.cs $(args) /out:$@

clean:
del /f clr.exe
rd /s /q bin || rem
rd /s /q obj || rem

$(outfile): $(entry) $(others)
$(csc) $^ /out:$@
.PHONY: clean
62 changes: 0 additions & 62 deletions cs/dotnetfx35installer.csproj

This file was deleted.

Binary file removed cs/dotnetfx35installer.exe
Binary file not shown.
25 changes: 0 additions & 25 deletions cs/dotnetfx35installer.sln

This file was deleted.

3 changes: 0 additions & 3 deletions cxx/.gitignore

This file was deleted.

10 changes: 5 additions & 5 deletions cxx/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ class EmbeddedFile {
};

int main() {
const auto temp = fs::temp_directory_path();
const auto outdir = temp / "dotnetfx35installer";
const auto outdir = fs::temp_directory_path() / "dotnetfx35installer";

cout << "Writing temporary files to " << temp << endl;
cout << "Writing temporary files to " << outdir << endl;
cout << "Does this look correct? Press 'y' to continue: ";
if (getchar() != 'y') {
return 0;
Expand Down Expand Up @@ -85,6 +84,7 @@ int main() {
source.c_str(),
nullptr,
};
cout << "Please be patient...\n";
auto e = _spawnv(_P_WAIT, dism, args);
if(e) {
cerr << "Couldn't spawn dsim.exe\n";
Expand All @@ -94,6 +94,6 @@ int main() {
cout << "Removed " << outdir << endl;
}
cout << "Press any key to exit...\n";
getchar();
getchar();
getchar(); // I'm not really sure about why I need two of these

This comment has been minimized.

Copy link
@falfiya

falfiya Sep 9, 2020

Author Owner

I was gonna say that maybe it had something to do with C++'s cursed stream thing but that doesn't even make any sense. I'm writing to stdout but getchar is for stdin. I guess I'll never know,

getchar(); // It works, though
}
28 changes: 10 additions & 18 deletions cxx/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
infile := Main.cxx
outfile := native.exe
nouac := __nouac__
manifest := ../dotnetfx35installer.manifest
include ../vars.mk

G11N := ../proprietary/microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab
L10N := ../proprietary/Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~en-US~.cab
infile := Main.cxx
outfile := x64.exe

vcvars = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" &&

native.exe.run: $(outfile)
$(outfile)

$(nouac): $(infile) res.res
clang $< res.res -v -o $@
$(outfile): $(infile) res.res
clang $< res.res -Wall -O2 -o $@
$(vcvars) mt -manifest $(manifest) -outputresource:$@;1

$(outfile): $(nouac)
$(vcvars) mt -manifest $(manifest) -outputresource:$<;1
del /f $(outfile)
MOVE $< $@

# default target
res.res: res.rc $(G11N) $(L10N)
$(vcvars) rc /V $<

res.rc: res.h

.PHONY: native.exe.run
clean:
del /f $(outfile) res.res

.PHONY: clean
8 changes: 7 additions & 1 deletion dotnetfx35installer.manifest
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Parts of this are handwritten. I hope it works... -->
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.2.0.0" name="dotnetfx35installer.native"/>
<assemblyIdentity version="2.0.0.0" name="dotnetfx35installer"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
4 changes: 4 additions & 0 deletions vars.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
manifest := ../dotnetfx35installer.manifest

G11N := ../proprietary/microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab
L10N := ../proprietary/Microsoft-Windows-NetFx3-OnDemand-Package~31bf3856ad364e35~amd64~en-US~.cab

0 comments on commit 113a4c6

Please sign in to comment.