-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run the Build target again instead of stripping annotations. Should c…
- Loading branch information
Showing
3 changed files
with
129 additions
and
76 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
src/ReSharper.ExportAnnotations.Task/build/ReSharper.ExportAnnotations.Task.Building.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<Project InitialTargets="_ExportAnnotations_CheckPreconditions"> | ||
|
||
<PropertyGroup> | ||
<MSBuildAllProjects Condition="'$(MSBuildToolsVersion)' != 'Current'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
|
||
<!-- Define the appropriate constant to embed annotations into compiled assembly --> | ||
<PropertyGroup> | ||
<DefineConstants Condition="'$(DefineConstants)' != ''">$(DefineConstants);</DefineConstants> | ||
<DefineConstants>$(DefineConstants)JETBRAINS_ANNOTATIONS</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<!-- Determine which ExportAnnotations executable to use and how, according to which kind of runtime MSBuild is running in. --> | ||
<PropertyGroup> | ||
|
||
<_ExportAnnotationsToolsDirectory>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\tools))\</_ExportAnnotationsToolsDirectory> | ||
|
||
<_ExportAnnotationsCommand Condition="'$(MSBuildRuntimeType)' == 'Core'">dotnet </_ExportAnnotationsCommand> | ||
<_ExportAnnotationsCommand Condition="'$(MSBuildRuntimeType)' == 'Full'" /> | ||
<_ExportAnnotationsCommand Condition="'$(MSBuildRuntimeType)' == 'Mono'">mono </_ExportAnnotationsCommand> | ||
|
||
<_ExportAnnotationsExe Condition="'$(MSBuildRuntimeType)' == 'Core'">$(_ExportAnnotationsToolsDirectory)netcoreapp2.1\ExportAnnotations.dll</_ExportAnnotationsExe> | ||
<_ExportAnnotationsExe Condition="'$(MSBuildRuntimeType)' == 'Full'">$(_ExportAnnotationsToolsDirectory)net471\ExportAnnotations.exe</_ExportAnnotationsExe> | ||
<_ExportAnnotationsExe Condition="'$(MSBuildRuntimeType)' == 'Mono'">$(_ExportAnnotationsToolsDirectory)net471\ExportAnnotations.exe</_ExportAnnotationsExe> | ||
|
||
<_ExportAnnotationsCommand>$(_ExportAnnotationsCommand)$(_ExportAnnotationsExe)</_ExportAnnotationsCommand> | ||
|
||
</PropertyGroup> | ||
|
||
<Target Name="_ExportAnnotations_CheckPreconditions"> | ||
|
||
<!-- Check for unsupported project type. --> | ||
<Error Condition="'$(MSBuildProjectExtension)' != '.csproj' And '$(MSBuildProjectExtension)' != '.vbproj'" | ||
Text="ReSharper.ExportAnnotations.Task: unsupported project type '$(MSBuildProjectExtension)' (only .csproj and .vbproj are supported)" /> | ||
|
||
<!-- Check for unsupported MSBuild runtime type. --> | ||
<Error Condition="'$(_ExportAnnotationsCommand)' == ''" | ||
Text="ReSharper.ExportAnnotations.Task: unsupported MSBuild runtime type '$(MSBuildRuntimeType)' (only Core, Full, and Mono are supported)" /> | ||
|
||
</Target> | ||
|
||
<!-- Run tool immediately after compiler --> | ||
<Target Name="_ExportAnnotations_RunTool" | ||
Condition="($(ExportJetBrainsAnnotations) Or $(StripJetBrainsAnnotations)) And ('$(SkipCompilerExecution)' != 'true')" | ||
AfterTargets="CoreCompile"> | ||
|
||
<PropertyGroup> | ||
<_ExportAnnotationsLibraryList>$(IntermediateOutputPath)ExportAnnotations.libraries</_ExportAnnotationsLibraryList> | ||
</PropertyGroup> | ||
|
||
<Message Importance="High" Text="Running ExportAnnotations..." /> | ||
|
||
<WriteLinesToFile File="$(_ExportAnnotationsLibraryList)" | ||
Lines="@(ReferencePathWithRefAssemblies)" | ||
Overwrite="true" /> | ||
|
||
<!-- Complete command line with options --> | ||
<PropertyGroup> | ||
<_ExportAnnotationsCommandLine>$(_ExportAnnotationsCommand) "%(IntermediateAssembly.FullPath)"</_ExportAnnotationsCommandLine> | ||
<_ExportAnnotationsCommandLine Condition="!$(ExportJetBrainsAnnotations)">$(_ExportAnnotationsCommandLine) --no-export</_ExportAnnotationsCommandLine> | ||
<_ExportAnnotationsCommandLine>$(_ExportAnnotationsCommandLine) --liblist "$(_ExportAnnotationsLibraryList)"</_ExportAnnotationsCommandLine> | ||
</PropertyGroup> | ||
|
||
<!-- Run for every IntermediateAssembly (item fed to Roslyn compilers as output assembly) --> | ||
<Exec Command="$(_ExportAnnotationsCommandLine)" /> | ||
|
||
</Target> | ||
|
||
<!-- Re-run the Build target without JetBrains annotations, only on non-outer, non-design-time builds. --> | ||
<Target Name="_BuildAgainWithoutJetBrainsAnnotations" | ||
Condition="$(StripJetBrainsAnnotations) And '$(TargetFramework)' != '' And '$(DesignTimeBuild)' != 'true'" | ||
AfterTargets="Build"> | ||
|
||
<Message Importance="High" Text="Rebuilding $(MSBuildProjectFile) without JetBrains annotations..." /> | ||
|
||
<ItemGroup> | ||
<_FilesToDeleteBeforeRebuildingWithoutJetBrainsAnnotations Include="@(IntermediateAssembly)" /> | ||
<_FilesToDeleteBeforeRebuildingWithoutJetBrainsAnnotations Include="@(MainAssembly)" /> | ||
</ItemGroup> | ||
|
||
<Delete Files="@(_FilesToDeleteBeforeRebuildingWithoutJetBrainsAnnotations)" /> | ||
|
||
<MSBuild Projects="$(MSBuildProjectFullPath)" | ||
Targets="Build" | ||
Properties="RebuildingWithoutJetBrainsAnnotations=true" /> | ||
|
||
</Target> | ||
|
||
</Project> |
26 changes: 26 additions & 0 deletions
26
...eSharper.ExportAnnotations.Task/build/ReSharper.ExportAnnotations.Task.Rebuilding.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<MSBuildAllProjects Condition="'$(MSBuildToolsVersion)' != 'Current'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
|
||
<!-- Hook into CopyFilesToOutputDirectory --> | ||
<Target Name="_ExportAnnotations_CopyFilesToOutputDirectory" | ||
Condition="$(ExportJetBrainsAnnotations)" | ||
AfterTargets="CopyFilesToOutputDirectory"> | ||
|
||
<Copy SourceFiles="@(IntermediateAssembly->'%(RootDir)%(Directory)%(Filename).ExternalAnnotations.xml')" | ||
DestinationFolder="$(OutDir)" | ||
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" | ||
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)" | ||
Retries="$(CopyRetryCount)" | ||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" | ||
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)" | ||
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)" | ||
Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'"> | ||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" /> | ||
</Copy> | ||
|
||
</Target> | ||
|
||
</Project> |
90 changes: 14 additions & 76 deletions
90
src/ReSharper.ExportAnnotations.Task/build/ReSharper.ExportAnnotations.Task.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,42 @@ | ||
<Project InitialTargets="_ExportAnnotations_CheckSupport"> | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<MSBuildAllProjects Condition="'$(MSBuildToolsVersion)' != 'Current'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
|
||
<!-- Build command line according to which kind of runtime MSBuild is running in --> | ||
<PropertyGroup> | ||
|
||
<_ExportAnnotationsToolsDirectory>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\tools))\</_ExportAnnotationsToolsDirectory> | ||
|
||
<_ExportAnnotationsCommand Condition="'$(MSBuildRuntimeType)' == 'Core'">dotnet </_ExportAnnotationsCommand> | ||
<_ExportAnnotationsCommand Condition="'$(MSBuildRuntimeType)' == 'Full'" /> | ||
<_ExportAnnotationsCommand Condition="'$(MSBuildRuntimeType)' == 'Mono'">mono </_ExportAnnotationsCommand> | ||
|
||
<_ExportAnnotationsExe Condition="'$(MSBuildRuntimeType)' == 'Core'">$(_ExportAnnotationsToolsDirectory)netcoreapp2.1\ExportAnnotations.dll</_ExportAnnotationsExe> | ||
<_ExportAnnotationsExe Condition="'$(MSBuildRuntimeType)' == 'Full'">$(_ExportAnnotationsToolsDirectory)net471\ExportAnnotations.exe</_ExportAnnotationsExe> | ||
<_ExportAnnotationsExe Condition="'$(MSBuildRuntimeType)' == 'Mono'">$(_ExportAnnotationsToolsDirectory)net471\ExportAnnotations.exe</_ExportAnnotationsExe> | ||
|
||
<_ExportAnnotationsCommand>$(_ExportAnnotationsCommand)$(_ExportAnnotationsExe)</_ExportAnnotationsCommand> | ||
|
||
</PropertyGroup> | ||
|
||
<!-- Issue errors on unsupported project type / MSBuild runtime type --> | ||
<Target Name="_ExportAnnotations_CheckSupport"> | ||
<Error Condition="'$(MSBuildProjectExtension)' != '.csproj' And '$(MSBuildProjectExtension)' != '.vbproj'" Text="ReSharper.ExportAnnotations.Task: unsupported project type '$(MSBuildProjectExtension)' (only .csproj and .vbproj are supported)" /> | ||
<Error Condition="'$(_ExportAnnotationsCommand)' == ''" Text="ReSharper.ExportAnnotations.Task: unsupported MSBuild runtime type '$(MSBuildRuntimeType)' (only Core, Full, and Mono are supported)" /> | ||
</Target> | ||
|
||
<!-- Normalize properties related to tool settings --> | ||
<!-- Unless set otherwise, ExportJetBrainsAnnotations is true for libraries, false for other projects. --> | ||
<PropertyGroup Condition="'$(ExportJetBrainsAnnotations)' == ''"> | ||
<ExportJetBrainsAnnotations Condition="'$(OutputType)' != 'Library'">false</ExportJetBrainsAnnotations> | ||
<ExportJetBrainsAnnotations Condition="'$(OutputType)' == 'Library'">true</ExportJetBrainsAnnotations> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<StripJetBrainsAnnotations Condition="'$(StripJetBrainsAnnotations)' == ''">true</StripJetBrainsAnnotations> | ||
<ExportJetBrainsAnnotations Condition="'$(ExportJetBrainsAnnotations)' != 'true'">false</ExportJetBrainsAnnotations> | ||
</PropertyGroup> | ||
|
||
<!-- Define the appropriate constant to embed annotations into compiled assembly --> | ||
<!-- Unless set otherwise, StripJetBrainsAnnotations is true. --> | ||
<PropertyGroup> | ||
<DefineConstants Condition="'$(DefineConstants)' != ''">$(DefineConstants);</DefineConstants> | ||
<DefineConstants>$(DefineConstants)JETBRAINS_ANNOTATIONS</DefineConstants> | ||
<StripJetBrainsAnnotations Condition="'$(StripJetBrainsAnnotations)' == ''">true</StripJetBrainsAnnotations> | ||
<StripJetBrainsAnnotations Condition="'$(StripJetBrainsAnnotations)' != 'true'">false</StripJetBrainsAnnotations> | ||
</PropertyGroup> | ||
|
||
<!-- Run tool immediately after compiler --> | ||
<Target Name="_ExportAnnotations_RunTool" | ||
Condition="($(ExportJetBrainsAnnotations) Or $(StripJetBrainsAnnotations)) And ('$(SkipCompilerExecution)' != 'true')" | ||
AfterTargets="CoreCompile"> | ||
|
||
<PropertyGroup> | ||
<_ExportAnnotationsLibraryList>$(IntermediateOutputPath)ExportAnnotations.libraries</_ExportAnnotationsLibraryList> | ||
</PropertyGroup> | ||
<Import Condition="'$(RebuildingWithoutJetBrainsAnnotations)' != 'true'" | ||
Project="ReSharper.ExportAnnotations.Task.Building.targets" /> | ||
|
||
<WriteLinesToFile | ||
File="$(_ExportAnnotationsLibraryList)" | ||
Lines="@(ReferencePathWithRefAssemblies)" | ||
Overwrite="true" /> | ||
<Import Condition="'$(RebuildingWithoutJetBrainsAnnotations)' == 'true'" | ||
Project="ReSharper.ExportAnnotations.Task.Rebuilding.targets" /> | ||
|
||
<!-- Complete command line with options --> | ||
<PropertyGroup> | ||
<_ExportAnnotationsCommandLine>$(_ExportAnnotationsCommand) "%(IntermediateAssembly.FullPath)"</_ExportAnnotationsCommandLine> | ||
<_ExportAnnotationsCommandLine Condition="!$(ExportJetBrainsAnnotations)">$(_ExportAnnotationsCommandLine) --no-export</_ExportAnnotationsCommandLine> | ||
<_ExportAnnotationsCommandLine Condition="$(StripJetBrainsAnnotations)">$(_ExportAnnotationsCommandLine) --strip</_ExportAnnotationsCommandLine> | ||
<_ExportAnnotationsCommandLine>$(_ExportAnnotationsCommandLine) --liblist "$(_ExportAnnotationsLibraryList)"</_ExportAnnotationsCommandLine> | ||
</PropertyGroup> | ||
|
||
<!-- Run for every IntermediateAssembly (item fed to Roslyn compilers as output assembly) --> | ||
<Exec Command="$(_ExportAnnotationsCommandLine)" /> | ||
|
||
</Target> | ||
|
||
<!-- Hook into CopyFilesToOutputDirectory --> | ||
<Target Name="_ExportAnnotations_CopyFilesToOutputDirectory" | ||
Condition="$(ExportJetBrainsAnnotations)" | ||
AfterTargets="CopyFilesToOutputDirectory"> | ||
|
||
<Copy SourceFiles="@(IntermediateAssembly->'%(RootDir)%(Directory)%(Filename).ExternalAnnotations.xml')" | ||
DestinationFolder="$(OutDir)" | ||
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" | ||
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)" | ||
Retries="$(CopyRetryCount)" | ||
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" | ||
UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)" | ||
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForCopyFilesToOutputDirectoryIfPossible)" | ||
Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'"> | ||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" /> | ||
</Copy> | ||
|
||
</Target> | ||
|
||
<!-- Hook into package creation to add external annotations file to package --> | ||
<!-- Add external annotations file to package --> | ||
<PropertyGroup Condition="$(ExportJetBrainsAnnotations)"> | ||
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_ExportAnnotations_IncludeExternalAnnotationsInPackage</TargetsForTfmSpecificContentInPackage> | ||
</PropertyGroup> | ||
|
||
<!-- Add external annotations file to package --> | ||
|
||
<Target Name="_ExportAnnotations_IncludeExternalAnnotationsInPackage" | ||
Condition="$(ExportJetBrainsAnnotations)"> | ||
|
||
<ItemGroup> | ||
<TfmSpecificPackageFile Include="$(OutputPath)\$(AssemblyName).ExternalAnnotations.xml" PackagePath="lib/$(TargetFramework)" /> | ||
</ItemGroup> | ||
|
||
</Target> | ||
|
||
</Project> |