Skip to content

Commit

Permalink
Fix msbuild failing when '@' is present in path (2nd attempt) (grpc#3…
Browse files Browse the repository at this point in the history
…1527)

* Fix msbuild failing when '@' is present in path

There was ambiguity in references to Source metadata on some Items. These
are now qualified to remove the ambiguity.

* Revert "Fix msbuild failing when '@' is present in path"

This reverts commit bb5d5dd.

* Unescape Indentity when creating Source

* Fix spelling in comment
  • Loading branch information
tonydnewell authored Nov 8, 2022
1 parent e73139e commit d3d2b64
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,12 @@
<!-- Remove files not for compile. -->
<Protobuf_Compile Remove="@(Protobuf_Compile)" Condition=" '%(ProtoCompile)' != 'true' " />
<!-- Ensure invariant Source=%(Identity). -->
<!-- Need to Unescape otherwise errors with characters such as '@' in paths
See https://github.com/grpc/grpc/issues/30746
and https://github.com/dotnet/msbuild/issues/8104
-->
<Protobuf_Compile>
<Source>%(Identity)</Source>
<Source>$([MSBuild]::Unescape(%(Identity)))</Source>
</Protobuf_Compile>
</ItemGroup>
</Target>
Expand Down Expand Up @@ -190,17 +194,24 @@
<ItemGroup>
<_Protobuf_CodeCompile Include="@(Protobuf_ExpectedOutputs->Distinct())"
Condition=" '%(Source)' != '' and '@(Protobuf_Compile->WithMetadataValue('CompileOutputs', 'true'))' != '' " />
<Compile Include="@(_Protobuf_CodeCompile)" />
<!-- Adding Distinct() is just a precaution as the CSC compiler complains if there are
duplicate source files
-->
<Compile Include="@(_Protobuf_CodeCompile->Distinct())" />
</ItemGroup>
</Target>

<!-- These invariants must be kept for compile up-to-date check to work. -->
<Target Name="_Protobuf_EnforceInvariants">
<!-- Enforce Source=Identity on proto files. The 'Source' metadata is used as a common
key to match dependencies/expected outputs in the lists for up-to-date checks. -->
<!-- Need to Unescape otherwise errors with characters such as '@' in paths
See https://github.com/grpc/grpc/issues/30746
and https://github.com/dotnet/msbuild/issues/8104
-->
<ItemGroup>
<Protobuf_Compile>
<Source>%(Identity)</Source>
<Source>$([MSBuild]::Unescape(%(Identity)))</Source>
</Protobuf_Compile>
</ItemGroup>

Expand Down

0 comments on commit d3d2b64

Please sign in to comment.