-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow --releasify
to specify the required .NET framework version
#940
Changes from 4 commits
609f5a6
1dc2a69
967ca61
ce5dea6
2b8d804
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
#pragma once | ||
|
||
enum class NetVersion {net45=0, net451=1, net452=2, net46=3, net461=4, net462=5}; | ||
|
||
class CFxHelper | ||
{ | ||
public: | ||
static NetVersion GetRequiredDotNetVersion(); | ||
static bool CanInstallDotNet4_5(); | ||
static bool IsDotNet45OrHigherInstalled(); | ||
static HRESULT InstallDotNetFramework(bool isQuiet); | ||
static bool IsDotNetInstalled(NetVersion requiredVersion); | ||
static HRESULT InstallDotNetFramework(NetVersion version, bool isQuiet); | ||
private: | ||
static HRESULT HandleRebootRequirement(bool isQuiet); | ||
static bool WriteRunOnceEntry(); | ||
static bool RebootSystem(); | ||
static int GetDotNetVersionReleaseNumber(NetVersion version); | ||
static UINT GetInstallerUrlForVersion(NetVersion version); | ||
static UINT GetInstallerMainInstructionForVersion(NetVersion version); | ||
static UINT GetInstallerContentForVersion(NetVersion version); | ||
static UINT GetInstallerExpandedInfoForVersion(NetVersion version); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ int executeCommandLine(string[] args) | |
string setupIcon = default(string); | ||
string icon = default(string); | ||
string shortcutArgs = default(string); | ||
string frameworkVersion = default(string); | ||
bool shouldWait = false; | ||
bool noMsi = (Environment.OSVersion.Platform != PlatformID.Win32NT); // NB: WiX doesn't work under Mono / Wine | ||
|
||
|
@@ -123,6 +124,7 @@ int executeCommandLine(string[] args) | |
{ "a=|process-start-args=", "Arguments that will be used when starting executable", v => processStartArgs = v, true}, | ||
{ "l=|shortcut-locations=", "Comma-separated string of shortcut locations, e.g. 'Desktop,StartMenu'", v => shortcutArgs = v}, | ||
{ "no-msi", "Don't generate an MSI package", v => noMsi = true}, | ||
{ "framework-version=", "Set the required .NET framework version, e.g. net461", v => frameworkVersion = v }, | ||
}; | ||
|
||
opts.Parse(args); | ||
|
@@ -173,7 +175,7 @@ int executeCommandLine(string[] args) | |
break; | ||
#endif | ||
case UpdateAction.Releasify: | ||
Releasify(target, releaseDir, packagesDir, bootstrapperExe, backgroundGif, signingParameters, baseUrl, setupIcon, !noMsi); | ||
Releasify(target, releaseDir, packagesDir, bootstrapperExe, backgroundGif, signingParameters, baseUrl, setupIcon, !noMsi, frameworkVersion); | ||
break; | ||
} | ||
} | ||
|
@@ -332,7 +334,7 @@ public async Task Uninstall(string appName = null) | |
} | ||
} | ||
|
||
public void Releasify(string package, string targetDir = null, string packagesDir = null, string bootstrapperExe = null, string backgroundGif = null, string signingOpts = null, string baseUrl = null, string setupIcon = null, bool generateMsi = true) | ||
public void Releasify(string package, string targetDir = null, string packagesDir = null, string bootstrapperExe = null, string backgroundGif = null, string signingOpts = null, string baseUrl = null, string setupIcon = null, bool generateMsi = true, string frameworkVersion = null) | ||
{ | ||
if (baseUrl != null) { | ||
if (!Utility.IsHttpUrl(baseUrl)) { | ||
|
@@ -434,8 +436,14 @@ public void Releasify(string package, string targetDir = null, string packagesDi | |
|
||
var writeZipToSetup = findExecutable("WriteZipToSetup.exe"); | ||
|
||
try { | ||
var result = Utility.InvokeProcessAsync(writeZipToSetup, String.Format("\"{0}\" \"{1}\"", targetSetupExe, zipPath), CancellationToken.None).Result; | ||
try | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please match the existing code style with braces |
||
{ | ||
var arguments = String.Format("\"{0}\" \"{1}\"", targetSetupExe, zipPath); | ||
if (!String.IsNullOrEmpty(frameworkVersion)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just default this to .NET 4.5? |
||
{ | ||
arguments += String.Format(" \"--set-required-framework\" \"{0}\"", frameworkVersion); | ||
} | ||
var result = Utility.InvokeProcessAsync(writeZipToSetup, arguments, CancellationToken.None).Result; | ||
if (result.Item1 != 0) throw new Exception("Failed to write Zip to Setup.exe!\n\n" + result.Item2); | ||
} catch (Exception ex) { | ||
this.Log().ErrorException("Failed to update Setup.exe with new Zip file", ex); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,8 +62,11 @@ int wmain(int argc, wchar_t* argv[]) | |
if (argc != 4) goto fail; | ||
return CopyResourcesToStubExecutable(argv[2], argv[3]); | ||
} | ||
|
||
if (argc != 3) { | ||
bool setFramework = false; | ||
if (argc == 5 && wcscmp(argv[3], L"--set-required-framework") == 0) { | ||
setFramework = true; | ||
} | ||
else if (argc != 3) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⬆️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused by what you'd like here. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind, that's a style change... |
||
goto fail; | ||
} | ||
|
||
|
@@ -107,6 +110,13 @@ int wmain(int argc, wchar_t* argv[]) | |
goto fail; | ||
} | ||
|
||
if (setFramework) { | ||
if (!UpdateResource(hRes, L"FLAGS", (LPCWSTR)132, 0x0409, argv[4], (wcslen(argv[4])+1) * sizeof(wchar_t))) { | ||
printf("Failed to update resouce\n"); | ||
goto fail; | ||
} | ||
} | ||
|
||
printf("Finished!\n"); | ||
if (!EndUpdateResource(hRes, false)) { | ||
printf("Failed to update resource\n"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to the previous line