Skip to content

Commit e2b8154

Browse files
committed
Copy necessary target and property files to support pre scenario all in one building.
1 parent 8c54d55 commit e2b8154

8 files changed

Lines changed: 128 additions & 21 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
<Target Name="PreparePayloadWorkItems" Inputs="@(PreparePayloadWorkItem)" Outputs="%(PreparePayloadWorkItem.Identity)">
3+
<Message Text="Command: %(PreparePayloadWorkItem.Command)" />
4+
<Exec Command="%(PreparePayloadWorkItem.Command)" WorkingDirectory="%(PreparePayloadWorkItem.WorkingDirectory)" />
5+
<Exec Command="$(AfterPreparePayloadWorkItemCommand)" WorkingDirectory="%(PreparePayloadWorkItem.WorkingDirectory)" Condition="'$(AfterPreparePayloadWorkItemCommand)' != ''" />
6+
</Target>
7+
</Project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project>
2+
<ItemGroup>
3+
<HelixCorrelationPayload Include="$(CorrelationPayloadDirectory)">
4+
<PayloadDirectory>%(Identity)</PayloadDirectory>
5+
</HelixCorrelationPayload>
6+
</ItemGroup>
7+
8+
<ItemDefinitionGroup>
9+
<HelixWorkItem>
10+
<Timeout>4:00</Timeout>
11+
</HelixWorkItem>
12+
</ItemDefinitionGroup>
13+
14+
<PropertyGroup>
15+
<FrameworkVersion>$(_Framework.Substring($([MSBuild]::Subtract($(_Framework.Length), 3))))</FrameworkVersion>
16+
</PropertyGroup>
17+
18+
<PropertyGroup Condition="'$(TargetsWindows)' == 'true'">
19+
<ScenariosDir>$(WorkItemDirectory)\src\scenarios\</ScenariosDir>
20+
<HelixPreCommands>$(HelixPreCommands);set PYTHONPATH=%HELIX_CORRELATION_PAYLOAD%\scripts%3B%HELIX_CORRELATION_PAYLOAD%</HelixPreCommands>
21+
<RID>win-$(Architecture)</RID>
22+
</PropertyGroup>
23+
24+
<PropertyGroup Condition="'$(TargetsWindows)' != 'true'">
25+
<ScenariosDir>$(WorkItemDirectory)/src/scenarios/</ScenariosDir>
26+
<HelixPreCommands>$(HelixPreCommands);sudo apt-get update;chmod +x $HELIX_CORRELATION_PAYLOAD/startup/perfcollect</HelixPreCommands>
27+
<HelixPreCommands>$(HelixPreCommands);export PYTHONPATH=$HELIX_CORRELATION_PAYLOAD/scripts:$HELIX_CORRELATION_PAYLOAD</HelixPreCommands>
28+
<RID>linux-$(Architecture)</RID>
29+
</PropertyGroup>
30+
</Project>

eng/performance/blazor_scenarios.proj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,6 @@
7979
</HelixWorkItem>
8080
</ItemGroup>
8181

82+
<Import Project="PreparePayloadWorkItems.targets" />
83+
8284
</Project>

eng/performance/maui_scenarios_android.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
<ItemGroup>
5252
<PreparePayloadWorkItem Include="@(MAUIAndroidScenario)">
53-
<Command>$(Python) pre.py publish -f $(PERFLAB_Framework)-android -o $(PreparePayloadWorkItemBaseDirectory)%(PreparePayloadWorkItem.ScenarioDirectoryName) -r android-arm64 --self-contained</Command>
53+
<Command>$(Python) pre.py publish -f $(_Framework)-android -o $(PreparePayloadWorkItemBaseDirectory)%(PreparePayloadWorkItem.ScenarioDirectoryName) -r android-arm64 --self-contained</Command>
5454
<WorkingDirectory>%(PreparePayloadWorkItem.PayloadDirectory)</WorkingDirectory>
5555
</PreparePayloadWorkItem>
5656
</ItemGroup>

eng/performance/scenarios.proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,6 @@
121121
post: %(HelixWorkItem.PostCommands)
122122
timeout: %(HelixWorkItem.Timeout) '"/>
123123
</Target> -->
124+
<Import Project="PreparePayloadWorkItems.targets" />
124125

125126
</Project>

eng/performance/scenarios.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ jobs:
104104
displayName: Build FailureReporter tool
105105
env:
106106
PERFLAB_TARGET_FRAMEWORKS: $(_Framework)
107+
- powershell: |
108+
$(Python) -m pip install --upgrade pip
109+
$(Python) -m pip install requests
110+
.\src\scenarios\init.ps1 -DotnetDirectory $(CorrelationStaging)dotnet
111+
dotnet --info
112+
dotnet msbuild .\eng\performance\${{ parameters.projectFile }} /restore /t:PreparePayloadWorkItems /bl:.\artifacts\log\$(_BuildConfig)\PrepareWorkItemPayloads.binlog
113+
displayName: Prepare scenarios
114+
env:
115+
CorrelationPayloadDirectory: $(CorrelationStaging)
116+
Architecture: ${{ parameters.architecture }}
117+
TargetsWindows: 'true'
118+
WorkItemDirectory: $(Build.SourcesDirectory)
119+
HelixTargetQueues: ${{ parameters.queue }}
107120
- ${{ if ne(parameters.osName, 'windows') }}:
108121
- script: cp ./NuGet.config $(CorrelationStaging);cp -r ./scripts $(CorrelationStaging)scripts;cp -r ./src/scenarios/shared $(CorrelationStaging)shared;cp -r ./src/scenarios/staticdeps $(CorrelationStaging)staticdeps
109122
displayName: Copy python libraries and NuGet.config
@@ -119,6 +132,19 @@ jobs:
119132
displayName: Build FailureReporter tool
120133
env:
121134
PERFLAB_TARGET_FRAMEWORKS: $(_Framework)
135+
- script: |
136+
$(Python) -m pip install --upgrade pip
137+
$(Python) -m pip install requests
138+
. ./src/scenarios/init.sh -dotnetdir $(CorrelationStaging)dotnet
139+
dotnet --info
140+
dotnet msbuild ./eng/performance/${{ parameters.projectFile }} /restore /t:PreparePayloadWorkItems /bl:./artifacts/log/$(_BuildConfig)/PrepareWorkItemPayloads.binlog
141+
displayName: Prepare scenarios
142+
env:
143+
CorrelationPayloadDirectory: $(CorrelationStaging)
144+
Architecture: ${{ parameters.architecture }}
145+
TargetsWindows: 'false'
146+
WorkItemDirectory: $(Build.SourcesDirectory)
147+
HelixTargetQueues: ${{ parameters.queue }}
122148
- template: /eng/performance/send-to-helix.yml
123149
parameters:
124150
HelixSource: '$(HelixSourcePrefix)/dotnet/performance/$(Build.SourceBranch)' # sources must start with pr/, official/, prodcon/, or agent/

eng/performance/sdk_scenarios.proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,6 @@
189189
<Timeout>4:00</Timeout>
190190
</HelixWorkItem>
191191
</ItemGroup>
192+
<Import Project="PreparePayloadWorkItems.targets" />
192193
</Project>
193194

src/scenarios/shared/precommands.py

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919
PUBLISH = 'publish'
2020
CROSSGEN = 'crossgen'
2121
CROSSGEN2 = 'crossgen2'
22+
EXTRACT = 'extract'
2223
DEBUG = 'Debug'
2324
RELEASE = 'Release'
2425

2526
OPERATIONS = (DEFAULT,
2627
BUILD,
2728
PUBLISH,
2829
CROSSGEN,
29-
CROSSGEN2
30+
CROSSGEN2,
31+
EXTRACT
3032
)
3133

3234
class PreCommands:
@@ -46,12 +48,30 @@ def __init__(self):
4648

4749
default_parser = subparsers.add_parser(DEFAULT, help='Default operation (placeholder command and no specific operation will be executed)' )
4850
self.add_common_arguments(default_parser)
51+
52+
extract_parser = subparsers.add_parser(EXTRACT, help='Used for local runs that extract the binaries to be run from a zip file. Requires a path to the zip' )
53+
self.add_common_arguments(extract_parser)
54+
extract_parser.add_argument('-p', '--pathtozip',
55+
dest='pathtozip',
56+
metavar='pathtozip',
57+
help='Path to the zip file to extract',
58+
required=True)
4959

5060
build_parser = subparsers.add_parser(BUILD, help='Builds the project')
5161
self.add_common_arguments(build_parser)
5262

5363
publish_parser = subparsers.add_parser(PUBLISH, help='Publishes the project')
5464
self.add_common_arguments(publish_parser)
65+
publish_parser.add_argument('--self-contained',
66+
dest='self_contained',
67+
default=False,
68+
action='store_true',
69+
help='Publish SCD')
70+
publish_parser.add_argument('--no-self-contained',
71+
dest='no_self_contained',
72+
default=False,
73+
action='store_true',
74+
help='Publish FDD')
5575

5676
crossgen_parser = subparsers.add_parser(CROSSGEN, help='Runs crossgen on a particular file')
5777
self.add_common_arguments(crossgen_parser)
@@ -77,11 +97,18 @@ def __init__(self):
7797
self.binlog = args.binlog
7898
self.has_workload = args.has_workload
7999
self.readonly_dotnet = args.readonly_dotnet
80-
100+
self.windows = args.windows
101+
self.output = args.output
102+
103+
if self.operation == PUBLISH:
104+
self.self_contained = args.self_contained
105+
self.no_self_contained = args.no_self_contained
81106
if self.operation == CROSSGEN:
82107
self.crossgen_arguments.parse_crossgen_args(args)
83108
if self.operation == CROSSGEN2:
84109
self.crossgen_arguments.parse_crossgen2_args(args)
110+
if self.operation == EXTRACT:
111+
self.pathtozip = args.pathtozip
85112

86113

87114
def new(self,
@@ -145,6 +172,14 @@ def add_common_arguments(self, parser: ArgumentParser):
145172
default=False,
146173
action='store_true',
147174
help='Indicates that the dotnet being used should not be modified (for example, when it is ahared with other builds)')
175+
parser.add_argument('--windowsui',
176+
dest='windows',
177+
action='store_true',
178+
help='must be set for UI tests so the proper rid is used')
179+
parser.add_argument('-o', '--output',
180+
dest='output',
181+
metavar='output',
182+
help='output directory')
148183
parser.set_defaults(configuration=RELEASE)
149184

150185
def existing(self, projectdir: str, projectfile: str):
@@ -160,12 +195,14 @@ def execute(self, build_args: list = []):
160195
pass
161196
if self.operation == BUILD:
162197
self._restore()
163-
self._build(configuration=self.configuration, framework=self.framework, build_args=build_args)
198+
self._build(configuration=self.configuration, framework=self.framework, output=self.output, build_args=build_args)
164199
if self.operation == PUBLISH:
165200
self._restore()
166-
self._publish(configuration=self.configuration,
167-
runtime_identifier=self.runtime_identifier,
168-
framework=self.framework, build_args=build_args)
201+
if self.self_contained:
202+
build_args.append('--self-contained')
203+
elif self.no_self_contained:
204+
build_args.append('--no-self-contained')
205+
self._publish(configuration=self.configuration, runtime_identifier=self.runtime_identifier, framework=self.framework, output=self.output, build_args=build_args)
169206
if self.operation == CROSSGEN:
170207
startup_args = [
171208
os.path.join(self.crossgen_arguments.coreroot, 'crossgen%s' % extension()),
@@ -230,30 +267,33 @@ def _parsemsbuildproperties(self) -> list:
230267
def _updateframework(self, projectfile: str):
231268
'Update the <TargetFramework> property so we can re-use the template'
232269
if self.framework:
233-
replace_line(projectfile, r'<TargetFramework>.*?</TargetFramework>', f'<TargetFramework>{self.framework}</TargetFramework>')
270+
if self.windows:
271+
replace_line(projectfile, r'<TargetFramework>.*?</TargetFramework>', f'<TargetFramework>{self.framework}-windows</TargetFramework>')
272+
else:
273+
replace_line(projectfile, r'<TargetFramework>.*?</TargetFramework>', f'<TargetFramework>{self.framework}</TargetFramework>')
234274

235-
def _publish(self, configuration: str, framework: str = None, runtime_identifier: str = None, build_args: list = []):
275+
def _publish(self, configuration: str, framework: str = None, runtime_identifier: str = None, output: str = None, build_args: list = []):
236276
self.project.publish(configuration,
237-
const.PUBDIR,
277+
output or const.PUBDIR,
238278
True,
239279
os.path.join(get_packages_directory(), ''), # blazor publish targets require the trailing slash for joining the paths
240-
framework,
280+
framework if not self.windows else f'{framework}-windows',
241281
runtime_identifier,
242282
self._parsemsbuildproperties(),
243-
'-bl:%s' % self.binlog if self.binlog else "",
244-
*build_args
245-
)
283+
*['-bl:%s' % self.binlog] if self.binlog else [],
284+
*build_args)
246285

247286
def _restore(self):
248287
self.project.restore(packages_path=get_packages_directory(), verbose=True)
249288

250-
def _build(self, configuration: str, framework: str = None, build_args: list = []):
251-
self.project.build(configuration=configuration,
252-
verbose=True,
253-
packages_path=get_packages_directory(),
254-
target_framework_monikers=[framework],
255-
output_to_bindir=True,
256-
*build_args)
289+
def _build(self, configuration: str, framework: str = None, output: str = None, build_args: list = []):
290+
self.project.build(configuration,
291+
True,
292+
get_packages_directory(),
293+
[framework],
294+
output is None,
295+
None,
296+
(['--output', output] if output else []) + build_args)
257297

258298
def _backup(self, projectdir:str):
259299
'Copy from projectdir to appdir so we do not modify the source code'

0 commit comments

Comments
 (0)