如果可能的话,我将不胜感激,请为以下问题提供一些帮助:我尝试通过命令行发布我的.NET 5.0控制台应用程序,因为我必须包含在ansible脚本中才能从jenkins构建和部署,当我尝试时以下命令:
dotnet publish --configuration Release -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true --runtime win-x86 --framework net5.0
我收到以下错误:
C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(2744,5): error : MSB4803: The task "ResolveComReference" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/msbuild/MSB4803 for further details. [I:\workspaceVS\net50\ConsoleCoreApp1\ConsoleCoreApp1.csproj]
根据我到目前为止所读到的内容,这是因为 dotnet 无法发布带有 COM 引用的项目。我有一个 .dll 文件作为 API,用于访问远程服务器以将数据传输到我的计算机。我首先需要 regsvr32 这个 .dll 文件,然后我可以在我的项目中引用它。
如果我尝试使用 VS2019 的发布功能,它可以工作,但我不想在 AWS 上的计算机上使用 VS2019,我只想安装 MSBuild 这样的工具,它将通过从 ansible 运行命令来构建和发布我的应用程序playbook(因此不要打开 VS2019 并单击按钮来发布应用程序)。
解决方案是使用 MSBuild。但如何……我不知道。
现在,在我尝试以下命令之后:
dotnet msbuild ConsoleCoreApp1.csproj /t:publish …
我想知道是否有人可以帮助解决以下情况:
我无法使用用 C# 编写并使用 .Net core 5.0 的 RabbitMQ Publisher解决内存泄漏问题。
这是 csproj 文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
...
</Project>
Run Code Online (Sandbox Code Playgroud)
我有一个在虚拟机内运行的 .net 控制台应用程序,该应用程序通过 API(注册的 64 位 dll 并引用为 COM 引用)连接到服务器,从该服务器获取信息,然后尝试将此信息发布到 RabbitMQ 机器位于 AWS 云上(此 RMQ 实例具有多个节点的负载均衡器)。
在代码中访问 API 的方式如下:
private void SetUpApi () {
Utils.log.Info (_api.SetAPIOptions ("<CONNECTIONOPTIONS><CALCULATED_PRICES Enabled='true' MaximumDepth='4'/></CONNECTIONOPTIONS>"));
_api.OnServerConnect += OnServerConnect;
_api.OnServerDisconnect += OnServerDisconnect;
_api.OnNewData += OnNewData;
}
Run Code Online (Sandbox Code Playgroud)
private void OnNewData(string strXML){
try{
if (strXML.Contains("<ORDER")){
ParseXMLAnswer(strXML, "OnNewData ()");
}
}
catch (Exception ex) {
if (ex.InnerException …Run Code Online (Sandbox Code Playgroud)