rules_dotnet icon indicating copy to clipboard operation
rules_dotnet copied to clipboard

How to run DotNetCliTools as part of build?

Open peakschris opened this issue 1 year ago • 3 comments

We have a csproj file that contains this section. The result is that dotnet generates a MyProject.XmlSerializers.dll as well as a MyProject.dll. Is this possible in rules_dotnet?

  <PropertyGroup>
    <SGenTypes>Utils.XmlBindingUtils</SGenTypes>
    <SGenProxyTypes>false</SGenProxyTypes>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Memory" Version="4.5.5" />
    <PackageReference Include="Microsoft.XmlSerializer.Generator" Version="7.0.0" />
    <DotNetCliToolReference Include="Microsoft.XmlSerializer.Generator" Version="7.0.0" />
  </ItemGroup>

Thank you, Chris

peakschris avatar Jun 10 '24 17:06 peakschris

This is not possible. You would have to create a custom genrule/rule for this. At some point I want add something similar to what rules_js has with js_run_binary where all tools in nuget packages are auto discovered.

purkhusid avatar Jun 11 '24 08:06 purkhusid

That would be great. What I'm finding as I try to create my own genrule calling dotnet.exe is that it's difficult to pass /r parameters for the reference assemblies that have been built or provided by paket/rules_dotnet, and I'm a bit lost on how to do this. Without these assmblies the dotnet command fails. Do you have any pointers?

peakschris avatar Jun 11 '24 18:06 peakschris

Resolved by https://github.com/bazel-contrib/rules_dotnet/pull/516 ?

njlr avatar Oct 29 '25 19:10 njlr