1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<MDBuildTasksAssembly>$(MSBuildThisFileDirectory)MDBuildTasks\bin\MDBuildTasks.dll</MDBuildTasksAssembly>
</PropertyGroup>
<!-- Ensure the tasks are built before any project that includes these files -->
<ItemGroup>
<ProjectReference
Include="$(MSBuildThisFileDirectory)MDBuildTasks\MDBuildTasks.csproj"
Project="{37E01D0B-8C44-441F-9F5D-56C36AB0B918}"
Name="MDBuildTasks"
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true"
/>
</ItemGroup>
<UsingTask TaskName="DownloadFiles" AssemblyFile="$(MDBuildTasksAssembly)" />
<UsingTask TaskName="DownloadNupkg" AssemblyFile="$(MDBuildTasksAssembly)" />
<UsingTask TaskName="GenerateExtensionContentManifest" AssemblyFile="$(MDBuildTasksAssembly)" />
<UsingTask TaskName="CollectExtensionContent" AssemblyFile="$(MDBuildTasksAssembly)" />
<UsingTask TaskName="FilterLocalCopyReferences" AssemblyFile="$(MDBuildTasksAssembly)" />
<!--
=================================================================
File download logic adapted from Xamarin.Build.Download
Files can be downloaded with <Download Include="url" />
* Hashes may be included in SHA1 or SHA2 metadata, and will be verified.
* By default the file will be downloaded to the project folder,
but this can be overridden with DownloadFolder.
* By default the file will use the filename from the URL, but this can
be overridden with DownloadName.
* If the file is a zip file, it can be unpacked by setting Unpack to
true.
=================================================================
-->
<Target Name="DownloadFiles" Condition="'@(Download)' != ''" AfterTargets="Build">
<DownloadFiles Downloads="@(Download)" />
</Target>
<!--
=================================================================
NuGet download logic
NuGets specified with <DownloadNupkg Include="id" Version="version">
items will be downloaded, and DownloadedNupkg items will be created
that point to the downloaded nupkgs
=================================================================
-->
<!--
FIXME: wire this into Restore when RoslynCodeTaskFactory works
and we no longer get it via a PackageReference
-->
<Target Name="DownloadNupkg"
Condition="'@(DownloadNupkg)' != ''"
BeforeTargets="ResolveAssemblyReferences"
DependsOnTargets="_DownloadNupkgPrepare;_DownloadNupkgIfNeeded" />
<Target Name="_DownloadNupkgPrepare">
<PropertyGroup>
<DownloadNupkgDirectory Condition="'$(DownloadNupkgDirectory)'==''">packages\</DownloadNupkgDirectory>
<DownloadNupkgDirectory Condition="!HasTrailingSlash('$(DownloadNupkgDirectory)')">$(DownloadNupkgDirectory)\</DownloadNupkgDirectory>
<_DownloadNupkgStamp>$(IntermediateOutputPath)MDDownloadFiles\stamp</_DownloadNupkgStamp>
<_DownloadNupkgPkgCfg>$(IntermediateOutputPath)MDDownloadFiles\packages.config</_DownloadNupkgPkgCfg>
</PropertyGroup>
</Target>
<Target Name="_DownloadNupkgIfNeeded" Inputs="$(MSBuildAllProjects)" Outputs="@(DownloadedNupkg);$(_DownloadNupkgStamp)" >
<DownloadNupkg
ToolPath="$(MSBuildThisFileDirectory)\..\external\nuget-binary"
ToolExe="nuget.exe"
Packages="@(DownloadNupkg)"
PackagesDirectory="$(DownloadNupkgDirectory)"
StampFile="$(_DownloadNupkgStamp)"
PackagesConfigFile="$(_DownloadNupkgPkgCfg)"
/>
</Target>
<Target Name="_DownloadNupkgGatherOutput" DependsOnTargets="DownloadNupkg">
<ItemGroup>
<DownloadedNupkg Include="@(DownloadNupkg->'$(DownloadNupkgDirectory)%(Identity).%(Version)\%(Identity).%(Version).nupkg')" />
<FileWrites Include="$(_DownloadNupkgStamp);$(_DownloadNupkgPkgCfg)" />
</ItemGroup>
<ItemGroup>
<ExtensionContent
Include="@(DownloadedNupkg->HasMetadata('ExtensionDir'))"
Link="$([MSBuild]::EnsureTrailingSlash('%(DownloadedNupkg.ExtensionDir)'))%(Filename)%(Extension)" />
<ExtensionContent
Include="@(DownloadedNupkg->HasMetadata('ExtensionPath'))"
Link="%(DownloadedNupkg.ExtensionPath)" />
</ItemGroup>
</Target>
<!--
=================================================================
ExtensionContent logic from AddinMaker
ExtensionContent items are copied into the output directory and
automatically included in the extension using a generated manifest
=================================================================
-->
<!--
beforetargets is kinda messy. We can't just go before PrepareResources, because that's _empty_ and actually
just depends on a bunch of other targets that do the real work, and we need to go before _those_.
SplitResourcesByCulture seems to be the first.
-->
<Target
Name="_PrepareExtensionResources"
BeforeTargets="SplitResourcesByCulture"
DependsOnTargets="_DownloadNupkgGatherOutput;_CollectExtensionOutputFiles;_GenerateExtensionContentManifest" />
<Target
Name="_CollectExtensionOutputFiles"
Condition="'@(ExtensionContent)' != ''"
>
<!--declare this here instead of toplevel so that IntermediateOutputPath has a value w/SDK style projects-->
<PropertyGroup>
<_ExtensionContentManifest>$(IntermediateOutputPath)_Manifest.addin.xml</_ExtensionContentManifest>
</PropertyGroup>
<CollectExtensionContent ExtensionContent="@(ExtensionContent)">
<Output TaskParameter="ExtensionContentWithLinkMetadata" ItemName="_ExtensionContentWithLinkMetadata" />
</CollectExtensionContent>
<ItemGroup>
<FileWrites Include="@(_ExtensionContentWithLinkMetadata->'$(OutputPath)%(Link)')" />
<FileWrites Include="$(_ExtensionContentManifest)" />
<EmbeddedResource Include="$(_ExtensionContentManifest)">
<LogicalName>_Manifest.addin.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Target>
<Target Name="_CopyExtensionOutputFiles"
Inputs="@(_ExtensionContentWithLinkMetadata)"
Outputs="@(_ExtensionContentWithLinkMetadata->'$(OutputPath)%(Link)')"
Condition="'@(_ExtensionContentWithLinkMetadata)' != ''"
BeforeTargets="PrepareForRun">
<Copy
SkipUnchangedFiles="True"
SourceFiles="@(_ExtensionContentWithLinkMetadata)"
DestinationFiles="@(_ExtensionContentWithLinkMetadata->'$(OutputPath)%(Link)')" />
</Target>
<Target Name="_GenerateExtensionContentManifest"
Inputs="$(MSBuildAllProjects);@(ExtensionContent)"
Outputs="$(_ExtensionContentManifest)">
<GenerateExtensionContentManifest
ManifestFile="$(_ExtensionContentManifest)"
ExtensionContentWithLinkMetadata="@(_ExtensionContentWithLinkMetadata)" />
<!-- disable these for now, they need fixup
ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
ExtensionDependencies="@(_ResolvedExtension)"
-->
</Target>
<!--
=================================================================
Remove CopyLocal items from references unless thir filenames
match an IncludeCopyLocal item.
This works around a NuGet issue where PrivateAssets="runtime"
doesn't work. It also prevents accidental unwanted local copying.
Additional diagnostic information can be printed by setting the
property -p:DebugFilterCopyReferences=true. This will print
which files are being removed, which are being kept, and
a list of probable IncludeCopyLocal items. Search the log
for "<IncludeCopyLocal Include=" and audit each occurrence. These
can be suppressed with corresponding SuppressCopyLocal items.
=================================================================
-->
<Target Name="_NuGetPrivateAssetsWorkaround_FilterLocalCopyReferences" BeforeTargets="_CopyFilesMarkedCopyLocal">
<FilterLocalCopyReferences
ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
IncludeList="@(IncludeCopyLocal)"
SuppressList="@(SuppressCopyLocal)"
ReferencedProjects="@(_MSBuildProjectReferenceExistent)"
Configuration="$(Configuration)"
Platform="$(Platform)"
ProjectDir="$(MSBuildProjectDirectory)"
ProjectName="$(MSBuildProjectName)"
DebugCopies="$(DebugFilterCopyReferences)">
<Output TaskParameter="ItemsToRemove" ItemName="_ReferenceCopyLocalPathsRemove" />
</FilterLocalCopyReferences>
<ItemGroup>
<ReferenceCopyLocalPaths Remove="@(_ReferenceCopyLocalPathsRemove)" />
<_ReferenceCopyLocalPathsRemove Remove="@(_ReferenceCopyLocalPathsRemove)" />
</ItemGroup>
</Target>
<!--
HACK: Another workaround for broken PrivateAssets.
This is injected directly into the project by a target from the package as a Content+CopyToOutputDirectory
item. Unlike the items added by NuGet itself there isn't any way we can generically identify things like
this so we have to resort to horrible hacks.
-->
<Target Name="_NuGetPrivateAssetsWorkaround_RemoveSqliteInjectedContent" Condition="'$(MSBuildProjectName)' != 'MonoDevelop.Core'" AfterTargets="ResolveAssemblyReferences">
<ItemGroup>
<Content Remove="@(Content->WithMetadataValue('Filename', 'libe_sqlite3'))" />
<Content Remove="@(Content->WithMetadataValue('Filename', 'e_sqlite3'))" />
<!-- for some reason it also shows up in ReferenceCopyLocalPaths in some projects, suppress the FilterLocalCopyReferences warning -->
<SuppressCopyLocal Include="e_sqlite3.dll" />
<SuppressCopyLocal Include="libe_sqlite3.dylib" />
<SuppressCopyLocal Include="libe_sqlite3.so" />
</ItemGroup>
</Target>
</Project>
|