-
|
I've taken a look through the issues, and certain discussions and can't quite figure out why I can't get the MSBuild package to generate the interfaces etc. <PackageReference Include="Refit" Version="8.0.0" />
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
<PackageReference Include="Refitter.MSBuild" Version="1.6.4" />I can get it working with SourceGenerator - however, our team would rather this happen at build time using MSBuild so that we don't have to check the generated files in. <PackageReference Include="Refit" Version="8.0.0" />
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
<PackageReference Include="Refitter.SourceGenerator" Version="1.6.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<ItemGroup>
<AdditionalFiles Include="openapi.json" />
<AdditionalFiles Include=".refitter" />
</ItemGroup>.refitter builder
.Services
.AddRefitClient<IPwClient>()
// ^^^ -- could not be found
.ConfigureHttpClient((sp, client) =>
{
...
})
.AddHttpMessageHandler<AuthenticationHandler>();Also as an aside, the source generator in VS2022 is a little strange in that you have to modify the refitter file to regenerate the generated code. Whereas, rebuilding or building the project doesn't regenerate.. which for the life of me I can't figure out why. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 15 replies
-
|
@david-pw thanks for taking the time to bring this to my attention I have this sample project with the MSBuild setup: and it seems to not work fine when running from Github Actions: The sample MSBuild project should fail to build as the Program.cs in the example uses the generated code, which doesn't exist in the git repo I made improvements over the MSBuild package over the summer to ensure that the generated code is included in the compilation but it seems to not work on my local machine anymore after I installed the .NET SDK 10.0.100-rc.1 😡 Let me see what I can do |
Beta Was this translation helpful? Give feedback.
-
|
@david-pw so it seems that it failed on my machine due a VS Code instance locking my .nuget/packages folder causing
When I clean up everything, restart my machine and start from scratch, everything works as it should
|
Beta Was this translation helpful? Give feedback.
-
|
@david-pw you can actually remove this <ItemGroup>
<AdditionalFiles Include="openapi.json" />
<AdditionalFiles Include=".refitter" />
</ItemGroup>The MSBuild package will do a recursive folder scan from the folder containing the .csproj file |
Beta Was this translation helpful? Give feedback.
-
I'm about to give up that source generator... it works fine when working with the CLI tools but it works so bad on Visual Studio. I think it's because I use the incremental source generator which was designed to only trigger when there are changes to file that is relevant to the source generator. The problem is that it's so unreliable. I spend most of my day in JetBrains Rider when working with C#, and for everything else I'm on VS Code or some text based editor like vim or helix |
Beta Was this translation helpful? Give feedback.


Closing the loop here: With the latest update to
1.6.5and making the following changes to my CSPROJ, MSbuild is generating the files just as the source generator would 🙂