|
49 | 49 | <VcpkgConfiguration>Release</VcpkgConfiguration> |
50 | 50 | </PropertyGroup> |
51 | 51 |
|
| 52 | + <!-- vcpkg can only install ports for one triplet at a time, so we need to ensure that every project using vcpkg uses the same triplet. |
| 53 | + If there is a triplet mismatch, the ports for one of the triplets will be deleted when installing a second one. |
| 54 | + In parallel builds, this can lead to projects that use the first triplet not being able to find the headers or binaries, and cause an error. --> |
| 55 | + |
52 | 56 | <PropertyGroup> |
53 | | - <_TripletFile>$(VcpkgInstalledDir)\.selectedtriplet</_TripletFile> |
| 57 | + <!-- The MSBuild process starts with the solution file, and each individual project is built recursively from there. |
| 58 | + When building the .sln, we will write a file to indicate which triplet should be used in all projects. |
| 59 | + Each project will later read this file to verify that it is using the same triplet. --> |
54 | 60 | <_IsBuildingSln>$(MSBuildProjectName.EndsWith('.sln'))</_IsBuildingSln> |
| 61 | + <_TripletFile>$(VcpkgInstalledDir)\.solutiontriplet</_TripletFile> |
55 | 62 | </PropertyGroup> |
56 | 63 |
|
57 | | - <Target Name="WriteSolutionTripletToFile" BeforeTargets="Build" Condition="'$(_IsBuildingSln)' == 'true'"> |
| 64 | + <Target Name="WriteSolutionTripletToFile" |
| 65 | + BeforeTargets="Build" |
| 66 | + Condition="'$(_IsBuildingSln)' == 'true'"> |
58 | 67 | <WriteLinesToFile File="$(_TripletFile)" Lines="$(VcpkgTriplet)" Overwrite="true" /> |
59 | 68 | </Target> |
60 | 69 |
|
61 | | - <Target Name="EnsureNoTripletMismatch" BeforeTargets="PrepareForBuild" Condition="'$(_IsBuildingSln)' != 'true'"> |
| 70 | + <Target Name="EnsureNoTripletMismatch" |
| 71 | + BeforeTargets="PrepareForBuild" |
| 72 | + Condition="'$(_IsBuildingSln)' != 'true'" > |
62 | 73 | <ReadLinesFromFile File="$(_TripletFile)"> |
63 | 74 | <Output TaskParameter="Lines" ItemName="_TripletFileLines" /> |
64 | 75 | </ReadLinesFromFile> |
65 | 76 |
|
66 | 77 | <PropertyGroup> |
67 | 78 | <_SolutionTriplet>@(_TripletFileLines)</_SolutionTriplet> |
68 | 79 | </PropertyGroup> |
69 | | - <Error Condition=" '$(_SolutionTriplet)' != '$(VcpkgTriplet)' " Text="The vcpkg triplet $(VcpkgTriplet) selected for this project does not match the solution triplet $(_SolutionTriplet)" /> |
| 80 | + |
| 81 | + <Error Condition=" '$(_SolutionTriplet)' != '$(VcpkgTriplet)' " |
| 82 | + Text="The vcpkg triplet $(VcpkgTriplet) selected for this project does not match the solution triplet $(_SolutionTriplet)" /> |
70 | 83 | </Target> |
71 | 84 | </Project> |
0 commit comments