-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extension validation step to CI #2756
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Just some organizational comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit on naming: Directory.Build.targets (lowercase t)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to eng/build
? Also recommend naming WorkerExtensions.targets
or something similar - so we can put all extension related targets into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For importing, in the root Directory.Build.props
, add this:
<PropertyGroup>
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
<EngRoot>$(RepoRoot)eng/</EngRoot>
<TargetsRoot>$(EngRoot)build/</TargetsRoot>
</PropertyGroup>
You can then use $(TargetsRoot)WorkerExtensions.targets
to import this file in the Directory.Build.targets
you are adding.
|
||
<Import Project="$(MSBuildThisFileDirectory)extensionValidation/GenerateExtensionValidationProjects.targets" /> | ||
|
||
<Target Name="AddWebJobsExtensionInformation" BeforeTargets="CoreCompile" Condition="'@(WebJobsExtension)' != ''"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move this target into GenerateExtensionValidationProjects.targets
</Target> | ||
|
||
<Target Name="BuildGeneratedExtensionProject" AfterTargets="GenerateExtensionProject" Condition="'@(WebJobsExtension)' != ''"> | ||
<MSBuild Projects="$(IntermediateOutputPath)\ExtensionValidation\ExtensionValidation.csproj" Targets="Restore;Build" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: use forward slashes /
. Also $(IntermediateOutputPath)
already includes a trailing slash.
I think we only need to restore to get the project.assets.json
, correct?
<MSBuild Projects="$(IntermediateOutputPath)\ExtensionValidation\ExtensionValidation.csproj" Targets="Restore;Build" /> | |
<MSBuild Projects="$(IntermediateOutputPath)ExtensionValidation/ExtensionValidation.csproj" Targets="Restore" /> |
<Target Name="GenerateExtensionProject" AfterTargets="Compile" Condition="'@(WebJobsExtension)' != ''"> | ||
<MakeDir Directories="$(IntermediateOutputPath)ExtensionValidation" /> | ||
<WriteLinesToFile | ||
File="$(IntermediateOutputPath)ExtensionValidation\ExtensionValidation.csproj" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File="$(IntermediateOutputPath)ExtensionValidation\ExtensionValidation.csproj" | |
File="$(IntermediateOutputPath)ExtensionValidation/ExtensionValidation.csproj" |
<Target Name="GenerateExtensionProject" AfterTargets="Compile" Condition="'@(WebJobsExtension)' != ''"> | ||
<MakeDir Directories="$(IntermediateOutputPath)ExtensionValidation" /> | ||
<WriteLinesToFile | ||
File="$(IntermediateOutputPath)ExtensionValidation\ExtensionValidation.csproj" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could pull $(IntermediateOutputPath)ExtensionValidation/ExtensionValidation.csproj
into a property for re-use.
Lines="$([System.IO.File]::ReadAllText($(_ExtensionProjectTemplate)) | ||
.Replace('$PackageName$', '%(WebJobsExtension.Identity)') | ||
.Replace('$PackageVersion$', '%(WebJobsExtension.Version)'))" | ||
Overwrite="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for now, but we may want to do some work for incremental build support. There are a few ways to do it, but primarily you want to only write to files if their contents have actually changed. By not writing to the csproj if it has not changed, restore will no-op as it will be already up to date.
Closing this as we are going to split this PR into two |
Issue describing the changes in this PR
resolves #2237
Pull request checklist
release_notes.md
Additional information
This PR introduces a target imported by each extension library that will generate a
.csproj
file referencing their respective WebJobs extension package. This will allow CI to build and restore these packages, producing aproject.assets.json
file that can be scanned by Component Governance. Full context in the linked issue.Important Change for Contributors
WebJobs extensions would no longer be referenced in
Properties/AssemblyInfo.cs
- they have been moved to the.csproj
file of each extension as an MS Build property. To update the WebJobs extension package, please update this new MS Build property,WebJobsExtension
.Testing Locally
/extensions
and build the project.bin/Debug/net8.0/ExtensionValidation
to see the generated file.