我如何以编程方式从运行.exe的机器获取MSBuild的路径?
我可以从环境中获取.NET版本但是有没有办法为.NET版本获取正确的文件夹?
如果可能的话,我将不胜感激,请为以下问题提供一些帮助:我尝试通过命令行发布我的.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 …