protected override void ExecuteCore() { OSPlatform targetOS = RuntimeIdentifier.StartsWith("win") ? OSPlatform.Windows : RuntimeIdentifier.StartsWith("osx") ? OSPlatform.OSX : OSPlatform.Linux; BundleOptions options = BundleOptions.BundleAllContent; options |= IncludeSymbols ? BundleOptions.BundleSymbolFiles : BundleOptions.None; var bundler = new Bundler(AppHostName, OutputDir, options, targetOS, new Version(TargetFrameworkVersion), ShowDiagnosticOutput); var fileSpec = new List <FileSpec>(FilesToBundle.Length); foreach (var item in FilesToBundle) { fileSpec.Add(new FileSpec(sourcePath: item.ItemSpec, bundleRelativePath: item.GetMetadata(MetadataKeys.RelativePath))); } bundler.GenerateBundle(fileSpec); // Certain files are excluded from the bundle, based on BundleOptions. // For example: // Native files and contents files are excluded by default. // hostfxr and hostpolicy are excluded until singlefilehost is available. // Return the set of excluded files in ExcludedFiles, so that they can be placed in the publish directory. ExcludedFiles = FilesToBundle.Zip(fileSpec, (item, spec) => (spec.Excluded) ? item : null).Where(x => x != null).ToArray(); }
public Target(string rootPath, FrameworkVersion version, RuntimeIdentifier runtimeIdentifier, ProgramMetadata metadata, IConsole console) { _rootPath = rootPath; _version = version; _runtimeIdentifier = runtimeIdentifier; _metadata = metadata; _console = console; }
protected override void ExecuteCore() { OSPlatform targetOS = RuntimeIdentifier.StartsWith("win") ? OSPlatform.Windows : RuntimeIdentifier.StartsWith("osx") ? OSPlatform.OSX : OSPlatform.Linux; Architecture targetArch = RuntimeIdentifier.EndsWith("-x64") || RuntimeIdentifier.Contains("-x64-") ? Architecture.X64 : RuntimeIdentifier.EndsWith("-x86") || RuntimeIdentifier.Contains("-x86-") ? Architecture.X86 : RuntimeIdentifier.EndsWith("-arm64") || RuntimeIdentifier.Contains("-arm64-") ? Architecture.Arm64 : RuntimeIdentifier.EndsWith("-arm") || RuntimeIdentifier.Contains("-arm-") ? Architecture.Arm : throw new ArgumentException(nameof(RuntimeIdentifier)); BundleOptions options = BundleOptions.None; options |= IncludeNativeLibraries ? BundleOptions.BundleNativeBinaries : BundleOptions.None; options |= IncludeAllContent ? BundleOptions.BundleAllContent : BundleOptions.None; options |= IncludeSymbols ? BundleOptions.BundleSymbolFiles : BundleOptions.None; options |= EnableCompressionInSingleFile ? BundleOptions.EnableCompression : BundleOptions.None; Version version = new Version(TargetFrameworkVersion); var bundler = new Bundler( AppHostName, OutputDir, options, targetOS, targetArch, version, ShowDiagnosticOutput); var fileSpec = new List <FileSpec>(FilesToBundle.Length); foreach (var item in FilesToBundle) { fileSpec.Add(new FileSpec(sourcePath: item.ItemSpec, bundleRelativePath: item.GetMetadata(MetadataKeys.RelativePath))); } bundler.GenerateBundle(fileSpec); // Certain files are excluded from the bundle, based on BundleOptions. // For example: // Native files and contents files are excluded by default. // hostfxr and hostpolicy are excluded until singlefilehost is available. // Return the set of excluded files in ExcludedFiles, so that they can be placed in the publish directory. ExcludedFiles = FilesToBundle.Zip(fileSpec, (item, spec) => (spec.Excluded) ? item : null).Where(x => x != null).ToArray(); }
public override bool Execute() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Log.LogError("MarkExecutableAsGui task can only be run on Windows."); return(false); } if (RuntimeIdentifier.EndsWith("-x64", StringComparison.Ordinal)) { mLinkerArchitecture = "x64"; } else if (RuntimeIdentifier.EndsWith("-x86", StringComparison.Ordinal)) { mLinkerArchitecture = "x86"; } else { Log.LogError("Could not determine the linker architecture from RID '{0}'", RuntimeIdentifier); return(false); } mVisualStudioPath = VSLocator.GetVisualStudioPath($"Microsoft.VisualCpp.Tools.HostX86.Target{mLinkerArchitecture.ToUpperInvariant()}"); string msvcToolsVersionFilePath = Path.Combine(mVisualStudioPath, @"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"); mMsvcToolsVersion = File.ReadAllLines(msvcToolsVersionFilePath)[0]; string[] pathAdditions = { Path.Combine(mVisualStudioPath, @"VC\Tools\MSVC", mMsvcToolsVersion, @"bin\HostX86", mLinkerArchitecture), Path.Combine(mVisualStudioPath, @"VC\Tools\MSVC", mMsvcToolsVersion, @"bin\HostX86\x86"), }; EnvironmentVariables = new[] { "PATH=" + string.Join(Path.PathSeparator.ToString(), pathAdditions) + Path.PathSeparator + Environment.GetEnvironmentVariable("PATH") }; return(base.Execute()); }
/// <summary> /// Initializes a new instance of the Grunt class. /// </summary> /// <param name="dotNetVersion">Possible values include: 'Net35', /// 'Net40', 'NetCore31'</param> /// <param name="runtimeIdentifier">Possible values include: 'win_x64', /// 'win_x86', 'win_arm', 'win_arm64', 'win7_x64', 'win7_x86', /// 'win81_x64', 'win81_x86', 'win81_arm', 'win10_x64', 'win10_x86', /// 'win10_arm', 'win10_arm64', 'linux_x64', 'linux_musl_x64', /// 'linux_arm', 'linux_arm64', 'rhel_x64', 'rhel_6_x64', 'tizen', /// 'tizen_4_0_0', 'tizen_5_0_0', 'osx_x64', 'osx_10_10_x64', /// 'osx_10_11_x64', 'osx_10_12_x64', 'osx_10_13_x64', 'osx_10_14_x64', /// 'osx_10_15_x64'</param> /// <param name="status">Possible values include: 'Uninitialized', /// 'Stage0', 'Stage1', 'Stage2', 'Active', 'Lost', 'Exited', /// 'Disconnected', 'Hidden'</param> /// <param name="integrity">Possible values include: 'Untrusted', /// 'Low', 'Medium', 'High', 'System'</param> public Grunt(string name, string originalServerGuid, int implantTemplateId, bool validateCert, bool useCertPinning, string smbPipeName, int delay, int jitterPercent, int connectAttempts, System.DateTime killDate, DotNetVersion dotNetVersion, RuntimeIdentifier runtimeIdentifier, GruntStatus status, IntegrityLevel integrity, int?id = default(int?), string guid = default(string), IList <string> children = default(IList <string>), ImplantTemplate implantTemplate = default(ImplantTemplate), int?listenerId = default(int?), Listener listener = default(Listener), string note = default(string), string process = default(string), string userDomainName = default(string), string userName = default(string), string ipAddress = default(string), string hostname = default(string), string operatingSystem = default(string), string gruntSharedSecretPassword = default(string), string gruntRSAPublicKey = default(string), string gruntNegotiatedSessionKey = default(string), string gruntChallenge = default(string), System.DateTime?activationTime = default(System.DateTime?), System.DateTime?lastCheckIn = default(System.DateTime?), string powerShellImport = default(string), IList <GruntCommand> gruntCommands = default(IList <GruntCommand>)) { Id = id; Name = name; OriginalServerGuid = originalServerGuid; Guid = guid; Children = children; ImplantTemplateId = implantTemplateId; ImplantTemplate = implantTemplate; ValidateCert = validateCert; UseCertPinning = useCertPinning; SmbPipeName = smbPipeName; ListenerId = listenerId; Listener = listener; Note = note; Delay = delay; JitterPercent = jitterPercent; ConnectAttempts = connectAttempts; KillDate = killDate; DotNetVersion = dotNetVersion; RuntimeIdentifier = runtimeIdentifier; Status = status; Integrity = integrity; Process = process; UserDomainName = userDomainName; UserName = userName; IpAddress = ipAddress; Hostname = hostname; OperatingSystem = operatingSystem; GruntSharedSecretPassword = gruntSharedSecretPassword; GruntRSAPublicKey = gruntRSAPublicKey; GruntNegotiatedSessionKey = gruntNegotiatedSessionKey; GruntChallenge = gruntChallenge; ActivationTime = activationTime; LastCheckIn = lastCheckIn; PowerShellImport = powerShellImport; GruntCommands = gruntCommands; CustomInit(); }
internal static string ToSerializedValue(this RuntimeIdentifier value) { switch (value) { case RuntimeIdentifier.WinX64: return("win_x64"); case RuntimeIdentifier.WinX86: return("win_x86"); case RuntimeIdentifier.WinArm: return("win_arm"); case RuntimeIdentifier.WinArm64: return("win_arm64"); case RuntimeIdentifier.Win7X64: return("win7_x64"); case RuntimeIdentifier.Win7X86: return("win7_x86"); case RuntimeIdentifier.Win81X64: return("win81_x64"); case RuntimeIdentifier.Win81X86: return("win81_x86"); case RuntimeIdentifier.Win81Arm: return("win81_arm"); case RuntimeIdentifier.Win10X64: return("win10_x64"); case RuntimeIdentifier.Win10X86: return("win10_x86"); case RuntimeIdentifier.Win10Arm: return("win10_arm"); case RuntimeIdentifier.Win10Arm64: return("win10_arm64"); case RuntimeIdentifier.LinuxX64: return("linux_x64"); case RuntimeIdentifier.LinuxMuslX64: return("linux_musl_x64"); case RuntimeIdentifier.LinuxArm: return("linux_arm"); case RuntimeIdentifier.LinuxArm64: return("linux_arm64"); case RuntimeIdentifier.RhelX64: return("rhel_x64"); case RuntimeIdentifier.Rhel6X64: return("rhel_6_x64"); case RuntimeIdentifier.Tizen: return("tizen"); case RuntimeIdentifier.Tizen400: return("tizen_4_0_0"); case RuntimeIdentifier.Tizen500: return("tizen_5_0_0"); case RuntimeIdentifier.OsxX64: return("osx_x64"); case RuntimeIdentifier.Osx1010X64: return("osx_10_10_x64"); case RuntimeIdentifier.Osx1011X64: return("osx_10_11_x64"); case RuntimeIdentifier.Osx1012X64: return("osx_10_12_x64"); case RuntimeIdentifier.Osx1013X64: return("osx_10_13_x64"); case RuntimeIdentifier.Osx1014X64: return("osx_10_14_x64"); case RuntimeIdentifier.Osx1015X64: return("osx_10_15_x64"); } return(null); }