Jetbrains Rider 指定运行时构建参数

huangapple go评论118阅读模式
英文:

Jetbrains Rider specify runtime build parameter

问题

在JetBrains Rider中,构建配置允许您在调用“构建项目”命令时更改传递的某些参数,但我找不到任何地方可以输入特定的运行时标识符。

我们希望提供特定的标识符,因为项目的某些依赖项使用本地库,如果未指定运行时,则会将这些库输出到一个名为“runtimes”的文件夹中,其中包含所有目标,当项目运行时,它不知道如何加载正确的库。通过指定运行时,只有该运行时的本地库会直接复制到输出 bin 文件夹中。

我们目前正在通过命令行使用 dotnet build -r osx-x64 MyProject.csproj 构建项目,然后通过Rider运行项目,但这不是一个良好的开发体验。

问题是,Rider中是否有一种配置可以在通过菜单或键绑定调用“构建”时指定要传递给 dotnet build 命令的运行时?

在这种情况下,特定的项目是一个C# Azure Functions项目,但对常规控制台项目也适用。

期望有一种方法可以为项目定义自定义构建参数。

英文:

In Jetbrains Rider, the Build Configurations let you change some of the parameters passed in when the Build Project command is invoked, but there's nowhere I can find to enter the specific Runtime Identifier.

The reason we'd like to provide a specific identifier, is because one of the project dependencies use native libraries that if the runtime is not specified, it outputs those libraries into a "runtimes" folder with all the targets inside, and when the project runs, it doesn't know how to load the proper one. By specifying a runtime, only the native libraries for that runtime are going to be copied directly into the output bin folder.

We are currently resorting to build the project through the command line using dotnet build -r osx-x64 MyProject.csproj, and then running the project through Rider, but that is not a good developer experience.

The question, is there a configuration in Rider that we can specify the runtime that's going to be passed into the dotnet build command when the Build is invoked through the menu, or Key Bindings?

The specific project in this case is an C# Azure Functions project, but it also applies to regular Console projects as well.

Expecting to have a way to define custom build arguments for projects

答案1

得分: 2

如果您不想在.csproj文件中指定它,可以使用工具集和构建设置(文件 -> 设置 -> 构建、执行、部署 -> 工具集和构建),然后在那里指定MSBuild全局属性

在您的情况下,这应该是名称 - RuntimeIdentifier 和值 - osx-x64

另请参阅:

英文:

If you do not want to specify it in .csproj you can use the Toolset and Build
settings (File -> Settings -> Build, Execution, Deployment -> Toolset and Build) and specify there MSBuild global properties:

Jetbrains Rider 指定运行时构建参数

In your case this should be name - RuntimeIdentifier and value osx-x64

See also:

huangapple
  • 本文由 发表于 2023年7月14日 02:15:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76682219.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定