1<?xml version="1.0"?> 2<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 3 <PropertyGroup> 4 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> 5 <!-- We allow a non-C# generator be set by the user, but skip adding outputs to Compile in this case. --> 6 <Protobuf_Generator Condition=" '$(Protobuf_Generator)' == '' and '$(Language)' == 'C#' ">CSharp</Protobuf_Generator> 7 <!-- Configuration is passing the smoke test. --> 8 <Protobuf_ProjectSupported Condition=" '$(Protobuf_Generator)' != '' ">true</Protobuf_ProjectSupported> 9 <!-- Allow assembly file to be specified externally for testing by setting property _Protobuf_MsBuildAssembly --> 10 <_Protobuf_MsBuildAssembly Condition=" '$(_Protobuf_MsBuildAssembly)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">netstandard1.3\Protobuf.MSBuild.dll</_Protobuf_MsBuildAssembly> 11 <_Protobuf_MsBuildAssembly Condition=" '$(_Protobuf_MsBuildAssembly)' == '' and '$(MSBuildRuntimeType)' != 'Core' ">net45\Protobuf.MSBuild.dll</_Protobuf_MsBuildAssembly> 12 </PropertyGroup> 13 14 <UsingTask AssemblyFile="$(_Protobuf_MsBuildAssembly)" TaskName="Grpc.Tools.ProtoToolsPlatform" /> 15 <UsingTask AssemblyFile="$(_Protobuf_MsBuildAssembly)" TaskName="Grpc.Tools.ProtoCompilerOutputs" /> 16 <UsingTask AssemblyFile="$(_Protobuf_MsBuildAssembly)" TaskName="Grpc.Tools.ProtoReadDependencies" /> 17 <UsingTask AssemblyFile="$(_Protobuf_MsBuildAssembly)" TaskName="Grpc.Tools.ProtoCompile" /> 18 19 <PropertyGroup Condition=" '$(Protobuf_ProjectSupported)' == 'true' "> 20 <Protobuf_IntermediatePath Condition=" '$(Protobuf_IntermediatePath)' == '' ">$(IntermediateOutputPath)</Protobuf_IntermediatePath> 21 <Protobuf_OutputPath Condition=" '$(Protobuf_OutputPath)' == '' ">$(Protobuf_IntermediatePath)</Protobuf_OutputPath> 22 <Protobuf_DepFilesPath Condition=" '$(Protobuf_DepFilesPath)' == '' ">$(Protobuf_IntermediatePath)</Protobuf_DepFilesPath> 23 </PropertyGroup> 24 25 <ItemDefinitionGroup Condition=" '$(Protobuf_ProjectSupported)' == 'true' and '$(Language)' == 'C#' "> 26 <Protobuf> 27 <Access Condition="'%(Protobuf.Access)' == '' ">Public</Access> 28 <ProtoCompile Condition="'%(Protobuf.ProtoCompile)' == '' ">True</ProtoCompile> 29 <ProtoRoot Condition="'%(Protobuf.ProtoRoot)' == '' " /> 30 <CompileOutputs Condition="'%(Protobuf.CompileOutputs)' == ''">True</CompileOutputs> 31 <OutputDir Condition="'%(Protobuf.OutputDir)' == '' ">$(Protobuf_OutputPath)</OutputDir> 32 <Generator Condition="'%(Protobuf.Generator)' == '' and '$(DisableProtobufDesignTimeBuild)' != 'true' " >MSBuild:Compile</Generator> 33 </Protobuf> 34 </ItemDefinitionGroup> 35 36 <ItemGroup Condition=" '$(Protobuf_ProjectSupported)' == 'true' and '$(Language)' == 'C#' "> 37 <PropertyPageSchema Include="$(MSBuildThisFileDirectory)Protobuf.CSharp.xml"> 38 <Context>File;BrowseObject</Context> 39 </PropertyPageSchema> 40 <AvailableItemName Include="Protobuf" /> 41 </ItemGroup> 42 43 <PropertyGroup> 44 <!-- NET SDK: by default, do not include proto files in the directory. 45 Current Microsoft's recommendation is against globbing: 46 https://docs.microsoft.com/en-us/dotnet/core/tools/csproj#recommendation --> 47 <EnableDefaultProtobufItems Condition=" '$(EnableDefaultProtobufItems)' == '' ">false</EnableDefaultProtobufItems> 48 </PropertyGroup> 49 50 <!-- Check configuration sanity before build. --> 51 <Target Name="_Protobuf_SanityCheck" BeforeTargets="PrepareForBuild"> 52 <Error 53 Condition=" '$(Protobuf_ProjectSupported)' != 'true' " 54 Text="Google.Protobuf.Tools proto compilation is only supported by default in a C# project (extension .csproj)" /> 55 </Target> 56 57 <!--================================================================================ 58 Tool path resolution 59 =================================================================================--> 60 61 <!-- Extension point for plugin packages: use Protobuf_ToolsOs and Protobuf_ToolsCpu 62 to resolve executable. Either or both may be blank, however, if resolution 63 fails; do check them before using. --> 64 <Target Name="Protobuf_ResolvePlatform"> 65 <ProtoToolsPlatform> 66 <Output TaskParameter="Os" PropertyName="_Protobuf_ToolsOs"/> 67 <Output TaskParameter="Cpu" PropertyName="_Protobuf_ToolsCpu"/> 68 </ProtoToolsPlatform> 69 70 <PropertyGroup> 71 <!-- First try environment variable. --> 72 <Protobuf_ToolsOs Condition=" '$(Protobuf_ToolsOs)' == '' ">$(PROTOBUF_TOOLS_OS)</Protobuf_ToolsOs> 73 <Protobuf_ToolsCpu Condition=" '$(Protobuf_ToolsCpu)' == '' ">$(PROTOBUF_TOOLS_CPU)</Protobuf_ToolsCpu> 74 <Protobuf_ProtocFullPath Condition=" '$(Protobuf_ProtocFullPath)' == '' ">$(PROTOBUF_PROTOC)</Protobuf_ProtocFullPath> 75 76 <!-- Next try OS and CPU resolved by ProtoToolsPlatform. --> 77 <Protobuf_ToolsOs Condition=" '$(Protobuf_ToolsOs)' == '' ">$(_Protobuf_ToolsOs)</Protobuf_ToolsOs> 78 <Protobuf_ToolsCpu Condition=" '$(Protobuf_ToolsCpu)' == '' ">$(_Protobuf_ToolsCpu)</Protobuf_ToolsCpu> 79 <Protobuf_ProtocFullPath Condition=" '$(Protobuf_ProtocFullPath)' == '' and '$(Protobuf_ToolsOs)' == 'windows' " 80 >$(Protobuf_PackagedToolsPath)\$(Protobuf_ToolsOs)_$(Protobuf_ToolsCpu)\protoc.exe</Protobuf_ProtocFullPath> 81 <Protobuf_ProtocFullPath Condition=" '$(Protobuf_ProtocFullPath)' == '' " 82 >$(Protobuf_PackagedToolsPath)/$(Protobuf_ToolsOs)_$(Protobuf_ToolsCpu)/protoc</Protobuf_ProtocFullPath> 83 </PropertyGroup> 84 85 <Error Condition=" '$(DisableProtobufDesignTimeBuild)' != 'true' and '$(PROTOBUF_PROTOC)' == '' 86 and ( '$(Protobuf_ToolsOs)' == '' or '$(Protobuf_ToolsCpu)' == '' ) " 87 Text="Google.Protobuf.Tools cannot determine host OS and CPU. Use environment variables PROTOBUF_TOOLS_OS={linux|macosx|windows} and PROTOBUF_TOOLS_CPU={x86|x64|arm64} to try the closest match to your system. You may also set PROTOBUF_PROTOC to specify full path to the host-provided compiler (v3.5+ is required)." /> 88 </Target> 89 90 <!--================================================================================ 91 Proto compilation 92 =================================================================================--> 93 94 <!-- Extension points. --> 95 <Target Name="Protobuf_BeforeCompile" /> 96 <Target Name="Protobuf_AfterCompile" /> 97 98 <!-- Main compile sequence. Certain steps are gated by the value $(DisableProtobufDesignTimeBuild), 99 so the sequence is good for either design time or build time. --> 100 <Target Name="Protobuf_Compile" 101 Condition=" '@(Protobuf)' != '' " 102 DependsOnTargets=" Protobuf_BeforeCompile; 103 Protobuf_ResolvePlatform; 104 _Protobuf_SelectFiles; 105 Protobuf_PrepareCompile; 106 _Protobuf_AugmentLanguageCompile; 107 _Protobuf_CoreCompile; 108 Protobuf_ReconcileOutputs; 109 Protobuf_AfterCompile" /> 110 111 <!-- Do proto compilation by default in a C# project. In other types, the user invoke 112 Protobuf_Compile directly where required. --> 113 <Target Name="_Protobuf_Compile_BeforeCsCompile" 114 BeforeTargets="BeforeCompile" 115 DependsOnTargets="Protobuf_Compile" 116 Condition=" '$(Language)' == 'C#' " /> 117 118 <Target Name="_Protobuf_SetProtoRoot"> 119 <!-- Guess .proto root for the files. Whenever the root is set for a file explicitly, 120 leave it as is. Otherwise, for files under the project directory, set the root 121 to "." for the project's directory, as it is the current when compiling; for the 122 files outside of project directory, use each .proto file's directory as the root. --> 123 <FindUnderPath Path="$(MSBuildProjectDirectory)" 124 Files="@(Protobuf->WithMetadataValue('ProtoRoot',''))"> 125 <Output TaskParameter="InPath" ItemName="_Protobuf_NoRootInProject"/> 126 <Output TaskParameter="OutOfPath" ItemName="_Protobuf_NoRootElsewhere"/> 127 </FindUnderPath> 128 <ItemGroup> 129 <!-- Files with explicit metadata. --> 130 <Protobuf_Rooted Include="@(Protobuf->HasMetadata('ProtoRoot'))" /> 131 <!-- In-project files will have ProtoRoot='.'. --> 132 <Protobuf_Rooted Include="@(_Protobuf_NoRootInProject)"> 133 <ProtoRoot>.</ProtoRoot> 134 </Protobuf_Rooted> 135 <!-- Out-of-project files will have respective ProtoRoot='%(RelativeDir)'. --> 136 <Protobuf_Rooted Include="@(_Protobuf_NoRootElsewhere)"> 137 <ProtoRoot>%(RelativeDir)</ProtoRoot> 138 <ProtoRoot Condition=" '$(Protobuf_ProtoRoot)' != '' ">$(Protobuf_ProtoRoot)</ProtoRoot> 139 </Protobuf_Rooted> 140 </ItemGroup> 141 </Target> 142 143 <!-- Select files that should be compiled. --> 144 <Target Name="_Protobuf_SelectFiles" 145 DependsOnTargets=" _Protobuf_SetProtoRoot"> 146 <ItemGroup> 147 <!-- Files with explicit metadata. --> 148 <Protobuf_Compile Include="@(Protobuf_Rooted)" /> 149 <!-- Remove files not for compile. --> 150 <Protobuf_Compile Remove="@(Protobuf_Compile)" Condition=" '%(ProtoCompile)' != 'true' " /> 151 <!-- Ensure invariant Source=%(Identity). --> 152 <!-- Need to Unescape otherwise errors with characters such as '@' in paths 153 See https://github.com/grpc/grpc/issues/30746 154 and https://github.com/dotnet/msbuild/issues/8104 155 --> 156 <Protobuf_Compile> 157 <Source>$([MSBuild]::Unescape(%(Identity)))</Source> 158 </Protobuf_Compile> 159 </ItemGroup> 160 </Target> 161 162 <!-- Extension point for non-C# project. Protobuf_Generator should be supported 163 by the ProtoCompile task, but we skip inferring expected outputs. All proto 164 files will be always recompiled with a warning, unless you add expectations 165 to the Protobuf_ExpectedOutputs collection. 166 167 All inferred ExpectedOutputs will be added to code compile (C#) in a C# project 168 by default. This is controlled per-proto by the CompileOutputs metadata. --> 169 <Target Name="Protobuf_PrepareCompile" Condition=" '@(Protobuf_Compile)' != '' "> 170 <!-- Predict expected names. --> 171 <ProtoCompilerOutputs Condition=" '$(Language)' == 'C#' " 172 Protobuf="@(Protobuf_Compile)" 173 Generator="$(Protobuf_Generator)"> 174 <Output TaskParameter="PossibleOutputs" ItemName="Protobuf_ExpectedOutputs" /> 175 <Output TaskParameter="PatchedProtobuf" ItemName="_PatchedProtobuf" /> 176 </ProtoCompilerOutputs> 177 <!-- Replace Protobuf_Compile with PatchedProtobuf. --> 178 <ItemGroup> 179 <Protobuf_Compile Remove="@(_PatchedProtobuf)"/> 180 <Protobuf_Compile Include ="@(_PatchedProtobuf)"/> 181 </ItemGroup> 182 <!-- Read any dependency files from previous compiles. --> 183 <ProtoReadDependencies Condition=" '$(Protobuf_DepFilesPath)' != '' and '$(DisableProtobufDesignTimeBuild)' != 'true' " 184 Protobuf="@(Protobuf_Compile)" 185 ProtoDepDir="$(Protobuf_DepFilesPath)" > 186 <Output TaskParameter="Dependencies" ItemName="Protobuf_Dependencies" /> 187 </ProtoReadDependencies> 188 </Target> 189 190 <!-- Add all expected outputs, and only these, to language compile. --> 191 <Target Name="_Protobuf_AugmentLanguageCompile" 192 DependsOnTargets="_Protobuf_EnforceInvariants" 193 Condition=" '$(Language)' == 'C#' "> 194 <ItemGroup> 195 <_Protobuf_CodeCompile Include="@(Protobuf_ExpectedOutputs->Distinct())" 196 Condition=" '%(Source)' != '' and '@(Protobuf_Compile->WithMetadataValue('CompileOutputs', 'true'))' != '' " /> 197 <!-- Adding Distinct() is just a precaution as the CSC compiler complains if there are 198 duplicate source files 199 --> 200 <Compile Include="@(_Protobuf_CodeCompile->Distinct())" /> 201 </ItemGroup> 202 </Target> 203 204 <!-- These invariants must be kept for compile up-to-date check to work. --> 205 <Target Name="_Protobuf_EnforceInvariants"> 206 <!-- Enforce Source=Identity on proto files. The 'Source' metadata is used as a common 207 key to match dependencies/expected outputs in the lists for up-to-date checks. --> 208 <!-- Need to Unescape otherwise errors with characters such as '@' in paths 209 See https://github.com/grpc/grpc/issues/30746 210 and https://github.com/dotnet/msbuild/issues/8104 211 --> 212 <ItemGroup> 213 <Protobuf_Compile> 214 <Source>$([MSBuild]::Unescape(%(Identity)))</Source> 215 </Protobuf_Compile> 216 </ItemGroup> 217 218 <!-- Remove possible output and dependency declarations that have no Source set, or those 219 not matching any proto marked for compilation. --> 220 <ItemGroup> 221 <Protobuf_ExpectedOutputs Remove="@(Protobuf_ExpectedOutputs)" Condition=" '%(Protobuf_ExpectedOutputs.Source)' == '' " /> 222 <Protobuf_ExpectedOutputs Remove="@(Protobuf_ExpectedOutputs)" Condition=" '%(Source)' != '' and '@(Protobuf_Compile)' == '' " /> 223 <Protobuf_Dependencies Remove="@(Protobuf_Dependencies)" Condition=" '%(Protobuf_Dependencies.Source)' == '' " /> 224 <Protobuf_Dependencies Remove="@(Protobuf_Dependencies)" Condition=" '%(Source)' != '' and '@(Protobuf_Compile)' == '' " /> 225 </ItemGroup> 226 </Target> 227 228 <!-- Gather files with and without known outputs, separately. --> 229 <Target Name="_Protobuf_GatherStaleFiles" 230 Condition=" '@(Protobuf_Compile)' != '' " 231 DependsOnTargets="_Protobuf_EnforceInvariants; _Protobuf_GatherStaleSimple; _Protobuf_GatherStaleBatched"> 232 <ItemGroup> 233 <!-- Drop outputs from MSBuild inference (they won't have the '_Exec' metadata). --> 234 <_Protobuf_OutOfDateProto Remove="@(_Protobuf_OutOfDateProto->WithMetadataValue('_Exec',''))" /> 235 </ItemGroup> 236 </Target> 237 238 <Target Name="_Protobuf_GatherStaleSimple"> 239 <!-- Simple selection: always compile files that have no declared outputs (but warn below). --> 240 <ItemGroup> 241 <_Protobuf_OutOfDateProto Include="@(Protobuf_Compile)" 242 Condition = " '%(Source)' != '' and '@(Protobuf_ExpectedOutputs)' == '' "> 243 <_Exec>true</_Exec> 244 </_Protobuf_OutOfDateProto> 245 </ItemGroup> 246 247 <!-- You are seeing this warning because there was no Protobuf_ExpectedOutputs items with 248 their Source attribute pointing to the proto files listed in the warning. Such files 249 will be recompiled on every build, as there is nothing to run up-to-date check against. 250 Set Protobuf_NoOrphanWarning to 'true' to suppress if this is what you want. --> 251 <Warning Condition=" '@(_Protobuf_OutOfDateProto)' != '' and '$(Protobuf_NoOrphanWarning)' != 'true' " 252 Text="The following files have no known outputs, and will be always recompiled as if out-of-date: @(_Protobuf_Orphans->' %(Identity)', '')" /> 253 </Target> 254 255 <Target Name="_Protobuf_GatherStaleBatched" 256 Inputs="@(Protobuf_Compile);%(Source);@(Protobuf_Dependencies);$(MSBuildAllProjects)" 257 Outputs="@(Protobuf_ExpectedOutputs)" > 258 <!-- The '_Exec' metadatum is set to distinguish really executed items from those MSBuild so 259 "helpfully" infers in a bucketed task. For the same reason, cannot use the intrinsic 260 ItemGroup task here. --> 261 <CreateItem Include="@(Protobuf_Compile)" AdditionalMetadata="_Exec=true"> 262 <Output TaskParameter="Include" ItemName="_Protobuf_OutOfDateProto"/> 263 </CreateItem> 264 </Target> 265 266 <!-- Extension point: Plugins massage metadata into recognized metadata 267 values passed to the ProtoCompile task. --> 268 <Target Name="Protobuf_PrepareCompileOptions" Condition=" '@(Protobuf_Compile)' != '' "> 269 <ItemGroup> 270 <Protobuf_Compile> 271 <_OutputOptions Condition=" '%(Protobuf_Compile.Access)' == 'Internal' ">%(Protobuf_Compile._OutputOptions);internal_access</_OutputOptions> 272 </Protobuf_Compile> 273 </ItemGroup> 274 </Target> 275 276 <Target Name="_Protobuf_CoreCompile" 277 Condition=" '$(DisableProtobufDesignTimeBuild)' != 'true' " 278 DependsOnTargets="Protobuf_PrepareCompileOptions;_Protobuf_GatherStaleFiles"> 279 <!-- Ensure output directories. --> 280 <MakeDir Directories="%(_Protobuf_OutOfDateProto.OutputDir)" /> 281 <MakeDir Directories="%(_Protobuf_OutOfDateProto.GrpcOutputDir)" /> 282 <MakeDir Directories="$(Protobuf_DepFilesPath)" /> 283 284 <!-- Force output to the current directory if the user has set it to empty. --> 285 <ItemGroup> 286 <_Protobuf_OutOfDateProto> 287 <OutputDir Condition=" '%(OutputDir)' == '' ">.</OutputDir> 288 </_Protobuf_OutOfDateProto> 289 </ItemGroup> 290 291 <ProtoCompile Condition=" '@(_Protobuf_OutOfDateProto)' != '' " 292 ToolExe="$(Protobuf_ProtocFullPath)" 293 Generator="$(Protobuf_Generator)" 294 Protobuf="%(_Protobuf_OutOfDateProto.Source)" 295 ProtoPath="%(_Protobuf_OutOfDateProto.AdditionalImportDirs);$(Protobuf_StandardImportsPath);%(_Protobuf_OutOfDateProto.ProtoRoot)" 296 ProtoDepDir="$(Protobuf_DepFilesPath)" 297 OutputDir="%(_Protobuf_OutOfDateProto.OutputDir)" 298 OutputOptions="%(_Protobuf_OutOfDateProto.OutputOptions);%(_Protobuf_OutOfDateProto._OutputOptions)" 299 GrpcPluginExe="%(_Protobuf_OutOfDateProto.GrpcPluginExe)" 300 GrpcOutputDir="%(_Protobuf_OutOfDateProto.GrpcOutputDir)" 301 GrpcOutputOptions="%(_Protobuf_OutOfDateProto.GrpcOutputOptions);%(_Protobuf_OutOfDateProto._GrpcOutputOptions)" 302 AdditionalProtocArguments="%(_Protobuf_OutOfDateProto.AdditionalProtocArguments)" 303 > 304 <Output TaskParameter="GeneratedFiles" ItemName="_Protobuf_GeneratedFiles"/> 305 </ProtoCompile> 306 307 <!-- Compute files expected but not in fact produced by protoc. --> 308 <ItemGroup Condition=" '@(_Protobuf_OutOfDateProto)' != '' "> 309 <Protobuf_ExpectedNotGenerated Include="@(Protobuf_ExpectedOutputs)" 310 Condition=" '%(Source)' != '' and '@(_Protobuf_OutOfDateProto)' != '' " /> 311 <Protobuf_ExpectedNotGenerated Remove="@(_Protobuf_GeneratedFiles)" /> 312 </ItemGroup> 313 </Target> 314 315 <!-- Extension point. Plugins and/or unsupported projects may take special care of the 316 Protobuf_ExpectedNotGenerated list in BeforeTargets. We just silently create the 317 missing outputs so that out-of-date checks work (we do not add them to language 318 compile though). You can empty this collection in your Before targets to do nothing. 319 The target is not executed if the proto compiler is not executed. --> 320 <Target Name="Protobuf_ReconcileOutputs" 321 Condition=" '$(DisableProtobufDesignTimeBuild)' != 'true' "> 322 <!-- Warn about unexpected/missing files outside object file directory only. 323 This should have happened because build was incorrectly customized. --> 324 <FindUnderPath Path="$(BaseIntermediateOutputPath)" Files="@(Protobuf_ExpectedNotGenerated)"> 325 <Output TaskParameter="InPath" ItemName="_Protobuf_ExpectedNotGeneratedInTemp"/> 326 <Output TaskParameter="OutOfPath" ItemName="_Protobuf_ExpectedNotGeneratedElsewhere"/> 327 </FindUnderPath> 328 329 <!-- Prevent unnecessary recompilation by silently creating empty files. This probably 330 has happened because a proto file with an rpc service was processed by the gRPC 331 plugin, and the user did not set GrpcOutput to None. When we treat outputs as 332 transient, we can do it permissively. --> 333 <Touch Files="@(_Protobuf_ExpectedNotGeneratedInTemp)" AlwaysCreate="true" /> 334 335 <!-- Also create empty files outside of the intermediate directory, if the user wants so. --> 336 <Touch Files="@(_Protobuf_ExpectedNotGeneratedElsewhere)" AlwaysCreate="true" 337 Condition=" '$(Protobuf_TouchMissingExpected)' == 'true' "/> 338 339 <!-- You are seeing this warning because there were some Protobuf_ExpectedOutputs items 340 (outside of the transient directory under obj/) not in fact produced by protoc. --> 341 <Warning Condition=" '@(_Protobuf_ExpectedNotGeneratedElsewhere)' != '' and $(Protobuf_NoWarnMissingExpected) != 'true' " 342 Text="Some expected protoc outputs were not generated. @(_Protobuf_ExpectedNotGeneratedElsewhere->' %(Identity)', '')" /> 343 </Target> 344 345 <!--================================================================================ 346 Proto cleanup 347 =================================================================================--> 348 349 <!-- We fully support cleanup only in a C# project. If extending the build for other 350 generators/plugins, then mostly roll your own. --> 351 352 <!-- Extension points. --> 353 <Target Name="Protobuf_BeforeClean" /> 354 <Target Name="Protobuf_AfterClean" /> 355 356 <!-- Main cleanup sequence. --> 357 <Target Name="Protobuf_Clean" 358 Condition=" '@(Protobuf)' != '' " 359 DependsOnTargets=" Protobuf_BeforeClean; 360 _Protobuf_SetProtoRoot; 361 Protobuf_PrepareClean; 362 _Protobuf_CoreClean; 363 Protobuf_AfterClean" /> 364 365 <!-- Do proto cleanup by default in a C# project. In other types, the user should 366 invoke Protobuf_Clean directly if required. --> 367 <Target Name="_Protobuf_Clean_AfterCsClean" 368 AfterTargets="CoreClean" 369 DependsOnTargets="Protobuf_Clean" 370 Condition=" '$(Protobuf_ProjectSupported)' == 'true' and '$(Language)' == 'C#' " /> 371 372 <!-- Extension point for non-C# project. ProtoCompilerOutputs is not invoked for 373 non-C# projects, since inferring protoc outputs is required, so this is a 374 no-op in other project types. In your extension target populate the 375 Protobuf_ExpectedOutputs with all possible output. An option is to include 376 all existing outputs using Include with a wildcard, if you know where to look. 377 378 Note this is like Protobuf_PrepareCompile, but uses @(Protobuf_Rooted) regardless 379 of the Compile metadata, to remove all possible outputs. Plugins should err 380 on the side of overextending the Protobuf_ExpectedOutputs here. 381 382 All ExpectedOutputs will be removed. --> 383 <Target Name="Protobuf_PrepareClean" Condition=" '@(Protobuf_Rooted)' != '' "> 384 <!-- Predict expected names. --> 385 <ProtoCompilerOutputs Condition=" '$(Language)' == 'C#' " 386 Protobuf="@(Protobuf_Rooted)" 387 Generator="$(Protobuf_Generator)"> 388 <Output TaskParameter="PossibleOutputs" ItemName="Protobuf_ExpectedOutputs" /> 389 </ProtoCompilerOutputs> 390 </Target> 391 392 <Target Name="_Protobuf_CoreClean"> 393 <ItemGroup> 394 <_Protobuf_Protodep Include="$(Protobuf_DepFilesPath)*.protodep" /> 395 </ItemGroup> 396 <Delete Files="@(Protobuf_ExpectedOutputs);@(_Protobuf_Protodep)" TreatErrorsAsWarnings="true" /> 397 </Target> 398 399 <!--================================================================================ 400 Design-time support 401 =================================================================================--> 402 403 <!-- Add all .proto files to the SourceFilesProjectOutputGroupOutput, so that: 404 * Visual Studio triggers a build when any of them changed; 405 * The Pack target includes .proto files into the source package. --> 406 <Target Name="_Protobuf_SourceFilesProjectOutputGroup" 407 BeforeTargets="SourceFilesProjectOutputGroup" 408 Condition=" '@(Protobuf)' != '' " > 409 <ItemGroup> 410 <SourceFilesProjectOutputGroupOutput Include="@(Protobuf->'%(FullPath)')" /> 411 </ItemGroup> 412 </Target> 413</Project> 414