diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c76369 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/.vscode/ +/bin/ +/cs/bin/ +/cs/obj/ +/cs/*.exe +/cxx/*.res +/cxx/*.exe diff --git a/App.config b/App.config deleted file mode 100644 index 2bb2d87..0000000 --- a/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..219fc10 --- /dev/null +++ b/Makefile @@ -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 diff --git a/app.manifest b/app.manifest deleted file mode 100644 index f53ca19..0000000 --- a/app.manifest +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/cs/.clr.exe b/cs/.clr.exe deleted file mode 100644 index 92af7f9..0000000 Binary files a/cs/.clr.exe and /dev/null differ diff --git a/cs/.gitignore b/cs/.gitignore deleted file mode 100644 index cd42ee3..0000000 --- a/cs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin/ -obj/ diff --git a/cs/AssemblyInfo.cs b/cs/AssemblyInfo.cs index ef9315a..55bf8d1 100644 --- a/cs/AssemblyInfo.cs +++ b/cs/AssemblyInfo.cs @@ -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")] diff --git a/cs/Main.cs b/cs/Main.cs index c7fac72..a1799e7 100644 --- a/cs/Main.cs +++ b/cs/Main.cs @@ -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(); } } diff --git a/cs/Makefile b/cs/Makefile index ff131f2..99b1cef 100644 --- a/cs/Makefile +++ b/cs/Makefile @@ -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 diff --git a/cs/dotnetfx35installer.csproj b/cs/dotnetfx35installer.csproj deleted file mode 100644 index d21c2ad..0000000 --- a/cs/dotnetfx35installer.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - - Debug - AnyCPU - {709FA7FE-1B9A-4839-8612-E457B6734EF6} - Exe - dotnetfx35installer - dotnetfx35installer - v4.7.2 - 512 - true - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - app.manifest - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cs/dotnetfx35installer.exe b/cs/dotnetfx35installer.exe deleted file mode 100644 index b5d4fff..0000000 Binary files a/cs/dotnetfx35installer.exe and /dev/null differ diff --git a/cs/dotnetfx35installer.sln b/cs/dotnetfx35installer.sln deleted file mode 100644 index 9449517..0000000 --- a/cs/dotnetfx35installer.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29306.81 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetfx35installer", "dotnetfx35installer.csproj", "{709FA7FE-1B9A-4839-8612-E457B6734EF6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {709FA7FE-1B9A-4839-8612-E457B6734EF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {709FA7FE-1B9A-4839-8612-E457B6734EF6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {709FA7FE-1B9A-4839-8612-E457B6734EF6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {709FA7FE-1B9A-4839-8612-E457B6734EF6}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F3F6E4E7-E4B3-48AA-BB26-EA13E63ECD93} - EndGlobalSection -EndGlobal diff --git a/cxx/.gitignore b/cxx/.gitignore deleted file mode 100644 index a14dbd5..0000000 --- a/cxx/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -__nouac__ -res.res -native.exe diff --git a/cxx/Main.cxx b/cxx/Main.cxx index 43ddbb9..6ec1661 100644 --- a/cxx/Main.cxx +++ b/cxx/Main.cxx @@ -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; @@ -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"; @@ -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 + getchar(); // It works, though } diff --git a/cxx/Makefile b/cxx/Makefile index 328cde2..a1c8768 100644 --- a/cxx/Makefile +++ b/cxx/Makefile @@ -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 diff --git a/dotnetfx35installer.manifest b/dotnetfx35installer.manifest index e26d5a9..212a975 100644 --- a/dotnetfx35installer.manifest +++ b/dotnetfx35installer.manifest @@ -1,6 +1,7 @@ + - + @@ -8,4 +9,9 @@ + + + + + diff --git a/vars.mk b/vars.mk new file mode 100644 index 0000000..95708e2 --- /dev/null +++ b/vars.mk @@ -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