云服务器可以做几个网站,临猗做网站,物业管理系统英文,百度搜索网页因为最近在写cobaltstrike的execute-assembly内存加载的c#项目 用visual studio2022编译#xff0c;最低net只能用6.0版本的#xff0c;并且execute-assembly不支持 我想使用4.x版本进行编译#xff0c;因为visual studio不支持#xff0c;那么使用命令行进行编译 因为要用…因为最近在写cobaltstrike的execute-assembly内存加载的c#项目 用visual studio2022编译最低net只能用6.0版本的并且execute-assembly不支持 我想使用4.x版本进行编译因为visual studio不支持那么使用命令行进行编译 因为要用到MSBuild.exe我直接选择低版本的 用x64或者另一个都可以只要ConsoleApp2.csproj写上对应属性就好
Project ToolsVersion4.0 xmlnshttp://schemas.microsoft.com/developer/msbuild/2003PropertyGroupOutputTypeExe/OutputTypeTargetFrameworkVersionv4.8/TargetFrameworkVersion !-- .NET Framework 4.8 --PlatformTargetx64/PlatformTarget !-- 目标处理器架构设置为 x64 --RootNamespaceConsoleApp2/RootNamespaceAssemblyNameConsoleApp2/AssemblyNameConfiguration Condition $(Configuration) Release/Configuration !-- 默认配置为 Release --Platform Condition $(Platform) x64/Platform !-- 默认平台为 x64 --OutputPathbin\$(Configuration)\/OutputPath !-- 输出路径 --/PropertyGroupItemGroupReference IncludeSystem /!-- 添加其他引用 --/ItemGroupItemGroupCompile IncludeProgram.cs /!-- 添加其他源文件 --/ItemGroupImport Project$(MSBuildToolsPath)\Microsoft.CSharp.targets /
/Project我的项目代码为
using System;namespace HelloWorldApp
{class Program{static void Main(string[] args){string name;if (args.Length 0){name args[0];Console.WriteLine($你好, {name}!);}else{Console.WriteLine(没有提供命令行参数。请输入您的名字:);} }}
}但是编译会报错
说明字符串插值不能使用 是在 C# 6.0 引入的而 .NET Framework 4.0 默认使用的 C# 编译器版本是 4.0它不支持这些特性 所以需要改成拼接参数如下
using System;namespace ConsoleApp2
{class Program{static void Main(string[] args){// 检查是否传入了命令行参数if (args.Length 0){// 如果传入了参数使用第一个参数string name args[0];Console.WriteLine(Hello, name !);}else{// 如果没有传入参数使用默认值string defaultName world;Console.WriteLine(Hello, defaultName !);}}}
}这样就可以成功生成了 在cobaltstrike中试试效果 可以看到成功达到效果那么接下来看看完成一些功能 https://github.com/breakid/SharpUtils有一些功能我来试试env的 可以看到成功显示出来env