Skip to content

Commit df48720

Browse files
Fadi Hannanguerrera
Fadi Hanna
authored andcommitted
Rename properties as agreed (PublishReadyToRun, PublishReadyToRunEmitSymbols, PublishReadyToRunExclude) (dotnet#3134)
Simplify R2R creation logic: No need to split ResolvedFilesToPublish into PublishAlways and PreserveNewest lists.
1 parent 4a9967e commit df48720

File tree

3 files changed

+51
-120
lines changed

3 files changed

+51
-120
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/PrepareForReadyToRunCompilation.cs

+19-27
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ namespace Microsoft.NET.Build.Tasks
1717
{
1818
public class PrepareForReadyToRunCompilation : TaskBase
1919
{
20-
public ITaskItem[] FilesToPublishAlways { get; set; }
21-
public ITaskItem[] FilesToPublishPreserveNewest { get; set; }
22-
public string[] ReadyToRunExcludeList { get; set; }
23-
public bool ReadyToRunEmitSymbols { get; set; }
20+
public ITaskItem[] FilesToPublish { get; set; }
21+
public string[] ExcludeList { get; set; }
22+
public bool EmitSymbols { get; set; }
2423

2524
[Required]
2625
public string OutputPath { get; set; }
@@ -39,29 +38,19 @@ public class PrepareForReadyToRunCompilation : TaskBase
3938
// Output lists of files to compile. Currently crossgen has to run in two steps, the first to generate the R2R image
4039
// and the second to create native PDBs for the compiled images (the output of the first step is an input to the second step)
4140
[Output]
42-
public ITaskItem[] ReadyToRunCompileListPublishAlways => _compileListPublishAlways.ToArray();
41+
public ITaskItem[] ReadyToRunCompileList => _compileList.ToArray();
4342
[Output]
44-
public ITaskItem[] ReadyToRunSymbolsCompileListPublishAlways => _symbolsCompileListPublishAlways.ToArray();
45-
[Output]
46-
public ITaskItem[] ReadyToRunCompileListPreserveNewest => _compileListPreserveNewest.ToArray();
47-
[Output]
48-
public ITaskItem[] ReadyToRunSymbolsCompileListPreserveNewest => _symbolsCompileListPreserveNewest.ToArray();
43+
public ITaskItem[] ReadyToRunSymbolsCompileList => _symbolsCompileList.ToArray();
4944

50-
// Output files to publish after compilation. These lists are equivalent to the input lists, but contain the new
45+
// Output files to publish after compilation. These lists are equivalent to the input list, but contain the new
5146
// paths to the compiled R2R images and native PDBs.
5247
[Output]
53-
public ITaskItem[] ReadyToRunFilesToPublishAlways => _r2rFilesPublishAlways.ToArray();
54-
[Output]
55-
public ITaskItem[] ReadyToRunFilesToPreserveNewest => _r2rFilesPreserveNewest.ToArray();
56-
57-
private List<ITaskItem> _compileListPublishAlways = new List<ITaskItem>();
58-
private List<ITaskItem> _compileListPreserveNewest = new List<ITaskItem>();
48+
public ITaskItem[] ReadyToRunFilesToPublish => _r2rFiles.ToArray();
5949

60-
private List<ITaskItem> _symbolsCompileListPublishAlways = new List<ITaskItem>();
61-
private List<ITaskItem> _symbolsCompileListPreserveNewest = new List<ITaskItem>();
50+
private List<ITaskItem> _compileList = new List<ITaskItem>();
51+
private List<ITaskItem> _symbolsCompileList = new List<ITaskItem>();
6252

63-
private List<ITaskItem> _r2rFilesPublishAlways = new List<ITaskItem>();
64-
private List<ITaskItem> _r2rFilesPreserveNewest = new List<ITaskItem>();
53+
private List<ITaskItem> _r2rFiles = new List<ITaskItem>();
6554

6655
private string _runtimeIdentifier;
6756
private string _packagePath;
@@ -119,8 +108,7 @@ protected override void ExecuteCore()
119108
CrossgenTool.SetMetadata("DiaSymReader", _diasymreaderPath);
120109

121110
// Process input lists of files
122-
ProcessInputFileList(FilesToPublishPreserveNewest, _compileListPreserveNewest, _symbolsCompileListPreserveNewest, _r2rFilesPreserveNewest);
123-
ProcessInputFileList(FilesToPublishAlways, _compileListPublishAlways, _symbolsCompileListPublishAlways, _r2rFilesPublishAlways);
111+
ProcessInputFileList(FilesToPublish, _compileList, _symbolsCompileList, _r2rFiles);
124112
}
125113

126114
void ProcessInputFileList(ITaskItem[] inputFiles, List<ITaskItem> imageCompilationList, List<ITaskItem> symbolsCompilationList, List<ITaskItem> r2rFilesPublishList)
@@ -153,10 +141,10 @@ void ProcessInputFileList(ITaskItem[] inputFiles, List<ITaskItem> imageCompilati
153141
r2rFilesPublishList.Add(r2rFileToPublish);
154142

155143
// Note: ReadyToRun PDB/Map files are not needed for debugging. They are only used for profiling, therefore the default behavior is to not generate them
156-
// unless an explicit ReadyToRunEmitSymbols flag is enabled by the app developer. There is also another way to profile that the runtime supports, which does
144+
// unless an explicit PublishReadyToRunEmitSymbols flag is enabled by the app developer. There is also another way to profile that the runtime supports, which does
157145
// not rely on the native PDBs/Map files, so creating them is really an opt-in option, typically used by advanced users.
158146
// For debugging, only the IL PDBs are required.
159-
if (ReadyToRunEmitSymbols)
147+
if (EmitSymbols)
160148
{
161149
string outputPDBImageRelativePath = null, outputPDBImage = null, createPDBCommand = null;
162150

@@ -205,11 +193,15 @@ void ProcessInputFileList(ITaskItem[] inputFiles, List<ITaskItem> imageCompilati
205193
bool InputFileEligibleForCompilation(ITaskItem file)
206194
{
207195
// Check if the file is explicitly excluded from being compiled
208-
if (ReadyToRunExcludeList != null)
196+
if (ExcludeList != null)
209197
{
210-
foreach (var item in ReadyToRunExcludeList)
198+
foreach (var item in ExcludeList)
199+
{
211200
if (String.Compare(Path.GetFileName(file.ItemSpec), item, true) == 0)
201+
{
212202
return false;
203+
}
204+
}
213205
}
214206

215207
// Check to see if this is a valid ILOnly image that we can compile

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets

+26-87
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,10 @@ Copyright (c) .NET Foundation. All rights reserved.
183183
============================================================
184184
-->
185185
<Target Name="CreateReadyToRunImages"
186-
Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0' And '$(ReadyToRun)' == 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'"
187-
DependsOnTargets="_ComputeResolvedFilesToPublishTypes;
188-
_PrepareForReadyToRunCompilation;
189-
_CreateR2RImagePreserveNewest;
190-
_CreateR2RSymbolsPreserveNewest;
191-
_CreateR2RImagePublishAlways;
192-
_CreateR2RSymbolsPublishAlways">
186+
Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0' And '$(PublishReadyToRun)' == 'true' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'"
187+
DependsOnTargets="_PrepareForReadyToRunCompilation;
188+
_CreateR2RImages;
189+
_CreateR2RSymbols">
193190

194191
<NETSdkError Condition="'@(_ReadyToRunCompilationFailures)' != ''" ResourceName="ReadyToRunCompilationFailed" />
195192

@@ -200,11 +197,8 @@ Copyright (c) .NET Foundation. All rights reserved.
200197
and do not replace them. IL PDBs are still required for debugging. Native PDBs emitted by the R2R compiler are
201198
only used for profiling purposes.
202199
-->
203-
<_ResolvedFileToPublishAlways Remove="@(_ReadyToRunCompileListPublishAlways)" />
204-
<_ResolvedFileToPublishAlways Include="@(_ReadyToRunFilesToPublishAlways)" />
205-
206-
<_ResolvedFileToPublishPreserveNewest Remove="@(_ReadyToRunCompileListPreserveNewest)" />
207-
<_ResolvedFileToPublishPreserveNewest Include="@(_ReadyToRunFilesToPreserveNewest)" />
200+
<ResolvedFileToPublish Remove="@(_ReadyToRunCompileList)" />
201+
<ResolvedFileToPublish Include="@(_ReadyToRunFilesToPublish)" />
208202
</ItemGroup>
209203

210204
</Target>
@@ -233,124 +227,69 @@ Copyright (c) .NET Foundation. All rights reserved.
233227
KnownFrameworkReferences="@(KnownFrameworkReference)"
234228
NETCoreSdkRuntimeIdentifier="$(NETCoreSdkRuntimeIdentifier)"
235229
OutputPath="$(_ReadyToRunOutputPath)"
236-
FilesToPublishAlways="@(_ResolvedFileToPublishAlways)"
237-
FilesToPublishPreserveNewest="@(_ResolvedFileToPublishPreserveNewest)"
238-
ReadyToRunExcludeList="@(ReadyToRunExclude)"
239-
ReadyToRunEmitSymbols="$(ReadyToRunEmitSymbols)">
230+
FilesToPublish="@(ResolvedFileToPublish)"
231+
ExcludeList="@(PublishReadyToRunExclude)"
232+
EmitSymbols="$(PublishReadyToRunEmitSymbols)">
240233

241234
<Output TaskParameter="CrossgenTool" ItemName="_CrossgenTool" />
242235

243-
<Output TaskParameter="ReadyToRunCompileListPublishAlways" ItemName="_ReadyToRunCompileListPublishAlways" />
244-
<Output TaskParameter="ReadyToRunSymbolsCompileListPublishAlways" ItemName="_ReadyToRunSymbolsCompileListPublishAlways" />
245-
246-
<Output TaskParameter="ReadyToRunCompileListPreserveNewest" ItemName="_ReadyToRunCompileListPreserveNewest" />
247-
<Output TaskParameter="ReadyToRunSymbolsCompileListPreserveNewest" ItemName="_ReadyToRunSymbolsCompileListPreserveNewest" />
236+
<Output TaskParameter="ReadyToRunCompileList" ItemName="_ReadyToRunCompileList" />
237+
<Output TaskParameter="ReadyToRunSymbolsCompileList" ItemName="_ReadyToRunSymbolsCompileList" />
248238

249-
<Output TaskParameter="ReadyToRunFilesToPublishAlways" ItemName="_ReadyToRunFilesToPublishAlways" />
250-
<Output TaskParameter="ReadyToRunFilesToPreserveNewest" ItemName="_ReadyToRunFilesToPreserveNewest" />
239+
<Output TaskParameter="ReadyToRunFilesToPublish" ItemName="_ReadyToRunFilesToPublish" />
251240

252241
</PrepareForReadyToRunCompilation>
253242

254243
</Target>
255244

256245
<!--
257246
============================================================
258-
_CreateR2RImagePreserveNewest
247+
_CreateR2RImages
259248
260-
Compiles assemblies in the _ReadyToRunCompileListPreserveNewest list into ReadyToRun images
249+
Compiles assemblies in the _ReadyToRunCompileList list into ReadyToRun images
261250
============================================================
262251
-->
263252
<UsingTask TaskName="RunReadyToRunCompiler" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
264-
<Target Name="_CreateR2RImagePreserveNewest"
265-
Inputs="@(_ReadyToRunCompileListPreserveNewest)"
266-
Outputs="%(_ReadyToRunCompileListPreserveNewest.OutputR2RImage)">
267-
268-
<!-- TODO: BUG - FIX ImplementationAssemblies to take managed implementation assemblies to use as crossgen references -->
269-
<RunReadyToRunCompiler CrossgenTool="@(_CrossgenTool)"
270-
ImplementationAssemblies="@(ResolvedFileToPublish)"
271-
CompilationEntry="@(_ReadyToRunCompileListPreserveNewest)"
272-
ContinueOnError="ErrorAndContinue">
273-
<Output TaskParameter="ExitCode" PropertyName="_ReadyToRunCompilerExitCode" />
274-
</RunReadyToRunCompiler>
275-
276-
<ItemGroup>
277-
<_ReadyToRunCompilationFailures Condition="'$(_ReadyToRunCompilerExitCode)' != '' And $(_ReadyToRunCompilerExitCode) != 0"
278-
Include="@(_ReadyToRunCompileListPreserveNewest)" />
279-
</ItemGroup>
280-
</Target>
281-
282-
<!--
283-
============================================================
284-
_CreateR2RSymbolsPreserveNewest
285-
286-
Emit native symbols for ReadyToRun images in the _ReadyToRunSymbolsCompileListPreserveNewest list
287-
============================================================
288-
-->
289-
<Target Name="_CreateR2RSymbolsPreserveNewest"
290-
Inputs="@(_ReadyToRunSymbolsCompileListPreserveNewest)"
291-
Outputs="%(_ReadyToRunSymbolsCompileListPreserveNewest.OutputPDBImage)">
292-
293-
<!-- TODO: BUG - FIX ImplementationAssemblies to take managed implementation assemblies to use as crossgen references -->
294-
<RunReadyToRunCompiler CrossgenTool="@(_CrossgenTool)"
295-
ImplementationAssemblies="@(ResolvedFileToPublish)"
296-
CompilationEntry="@(_ReadyToRunSymbolsCompileListPreserveNewest)"
297-
ContinueOnError="ErrorAndContinue">
298-
<Output TaskParameter="ExitCode" PropertyName="_ReadyToRunCompilerExitCode" />
299-
</RunReadyToRunCompiler>
300-
301-
<ItemGroup>
302-
<_ReadyToRunCompilationFailures Condition="'$(_ReadyToRunCompilerExitCode)' != '' And $(_ReadyToRunCompilerExitCode) != 0"
303-
Include="@(_ReadyToRunSymbolsCompileListPreserveNewest)" />
304-
</ItemGroup>
305-
</Target>
306-
307-
<!--
308-
============================================================
309-
_CreateR2RImagePublishAlways
310-
311-
Compiles assemblies in the _ReadyToRunCompileListPublishAlways list into ReadyToRun images
312-
============================================================
313-
-->
314-
<Target Name="_CreateR2RImagePublishAlways"
315-
Inputs="@(_ReadyToRunCompileListPublishAlways)"
316-
Outputs="%(_ReadyToRunCompileListPublishAlways.OutputR2RImage)">
253+
<Target Name="_CreateR2RImages"
254+
Inputs="@(_ReadyToRunCompileList)"
255+
Outputs="%(_ReadyToRunCompileList.OutputR2RImage)">
317256

318257
<!-- TODO: BUG - FIX ImplementationAssemblies to take managed implementation assemblies to use as crossgen references -->
319258
<RunReadyToRunCompiler CrossgenTool="@(_CrossgenTool)"
320259
ImplementationAssemblies="@(ResolvedFileToPublish)"
321-
CompilationEntry="@(_ReadyToRunCompileListPublishAlways)"
260+
CompilationEntry="@(_ReadyToRunCompileList)"
322261
ContinueOnError="ErrorAndContinue">
323262
<Output TaskParameter="ExitCode" PropertyName="_ReadyToRunCompilerExitCode" />
324263
</RunReadyToRunCompiler>
325264

326265
<ItemGroup>
327266
<_ReadyToRunCompilationFailures Condition="'$(_ReadyToRunCompilerExitCode)' != '' And $(_ReadyToRunCompilerExitCode) != 0"
328-
Include="@(_ReadyToRunCompileListPublishAlways)" />
267+
Include="@(_ReadyToRunCompileList)" />
329268
</ItemGroup>
330269
</Target>
331270

332271
<!--
333272
============================================================
334-
_CreateR2RSymbolsPublishAlways
273+
_CreateR2RSymbols
335274
336-
Emit native symbols for ReadyToRun images in the _ReadyToRunSymbolsCompileListPublishAlways list
275+
Emit native symbols for ReadyToRun images in the _ReadyToRunSymbolsCompileList list
337276
============================================================
338277
-->
339-
<Target Name="_CreateR2RSymbolsPublishAlways"
340-
Inputs="@(_ReadyToRunSymbolsCompileListPublishAlways)"
341-
Outputs="%(_ReadyToRunSymbolsCompileListPublishAlways.OutputPDBImage)">
278+
<Target Name="_CreateR2RSymbols"
279+
Inputs="@(_ReadyToRunSymbolsCompileList)"
280+
Outputs="%(_ReadyToRunSymbolsCompileList.OutputPDBImage)">
342281

343282
<!-- TODO: BUG - FIX ImplementationAssemblies to take managed implementation assemblies to use as crossgen references -->
344283
<RunReadyToRunCompiler CrossgenTool="@(_CrossgenTool)"
345284
ImplementationAssemblies="@(ResolvedFileToPublish)"
346-
CompilationEntry="@(_ReadyToRunSymbolsCompileListPublishAlways)"
285+
CompilationEntry="@(_ReadyToRunSymbolsCompileList)"
347286
ContinueOnError="ErrorAndContinue">
348287
<Output TaskParameter="ExitCode" PropertyName="_ReadyToRunCompilerExitCode" />
349288
</RunReadyToRunCompiler>
350289

351290
<ItemGroup>
352291
<_ReadyToRunCompilationFailures Condition="'$(_ReadyToRunCompilerExitCode)' != '' And $(_ReadyToRunCompilerExitCode) != 0"
353-
Include="@(_ReadyToRunSymbolsCompileListPublishAlways)" />
292+
Include="@(_ReadyToRunSymbolsCompileList)" />
354293
</ItemGroup>
355294
</Target>
356295

src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunCrossgen.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public void It_creates_readytorun_images_for_all_assemblies_except_excluded_ones
5656
projectName,
5757
"ClassLib");
5858

59-
testProject.AdditionalProperties["ReadyToRun"] = "True";
60-
testProject.AdditionalItems["ReadyToRunExclude"] = "Classlib.dll";
59+
testProject.AdditionalProperties["PublishReadyToRun"] = "True";
60+
testProject.AdditionalItems["PublishReadyToRunExclude"] = "Classlib.dll";
6161

6262
var testProjectInstance = _testAssetsManager.CreateTestProject(testProject)
6363
.Restore(Log, testProject.Name);
@@ -96,8 +96,8 @@ public void It_creates_readytorun_symbols_when_switch_is_used(string targetFrame
9696
projectName,
9797
"ClassLib");
9898

99-
testProject.AdditionalProperties["ReadyToRun"] = "True";
100-
testProject.AdditionalProperties["ReadyToRunEmitSymbols"] = "True";
99+
testProject.AdditionalProperties["PublishReadyToRun"] = "True";
100+
testProject.AdditionalProperties["PublishReadyToRunEmitSymbols"] = "True";
101101

102102
var testProjectInstance = _testAssetsManager.CreateTestProject(testProject)
103103
.Restore(Log, testProject.Name);
@@ -136,7 +136,7 @@ public void It_does_not_support_framework_dependent_publishing(string targetFram
136136
projectName,
137137
"ClassLib");
138138

139-
testProject.AdditionalProperties["ReadyToRun"] = "True";
139+
testProject.AdditionalProperties["PublishReadyToRun"] = "True";
140140

141141
var testProjectInstance = _testAssetsManager.CreateTestProject(testProject)
142142
.Restore(Log, testProject.Name);
@@ -194,7 +194,7 @@ public void It_does_not_support_cross_platform_readytorun_compilation(string tar
194194
return;
195195
}
196196

197-
testProject.AdditionalProperties["ReadyToRun"] = "True";
197+
testProject.AdditionalProperties["PublishReadyToRun"] = "True";
198198

199199
var testProjectInstance = _testAssetsManager.CreateTestProject(testProject)
200200
.Restore(Log, testProject.Name);

0 commit comments

Comments
 (0)