-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
For incremental builds, should -Outputs allow empty lists? #48
Comments
The way around is to return paths of the expected items. Let me think if this requirement/error can be removed for simple incremental tasks. Presumably, it cannot for partial incremental. |
One workaround I've been trying to come up with is using Join-Path to generate the file paths which may not exist yet (before the first full restore or build of my .NET projects). Here's an example: task Restore `
-Inputs { Get-ChildItem -Recurse *.csproj } `
-Outputs { Join-Path (Get-ChildItem .\src, .\test -Directory | Select-Object -ExpandProperty FullName) -ChildPath "obj\project.assets.json" } `
-Before Build, BuildHost, Test {
exec { & $script:dotnetExe restore }
} Strangely this doesn't work for some reason, though, if I take the first item of the array returned by the ScriptBlock given to Outputs it does work: task Restore `
-Inputs { Get-ChildItem -Recurse *.csproj } `
-Outputs { (Join-Path (Get-ChildItem .\src, .\test -Directory | Select-Object -ExpandProperty FullName) -ChildPath "obj\project.assets.json")[0] } `
-Before Build, BuildHost, Test {
exec { & $script:dotnetExe restore }
} |
@daviwil, can you describe your original outputs that did not work as you IB expects required paths for output, including missing paths, i.e. not Example of the correct usage:
Example of the tempting but not supported/correct usage:
Suppose we support the second case. Then we have a problem. Imagine, in the I recall that I twitted you that outputs may be either paths or items. Please, describe your use case. I understand the inputs are all .csproj files. |
And so far it looks like Invoke-Build throws the error correctly. By the current design, outputs are all expected output paths. The case with no outputs is not valid. |
If I understand your case correctly, here is one possible solution $RestoreInputs = Get-ChildItem -Recurse *.csproj
$RestoreOutputs = $(
foreach ($item in $RestoreInputs) {
Join-Path $item.DirectoryName obj/project.assets.json
}
) Then we use Let me repeat, we cannot use anything like Yes, if all project.assets.json are missing then the task must not be skipped. |
Understood, Outputs must be statically-generated paths. However, that's what I'm doing in this example and it doesn't seem to work: task Restore `
-Inputs { Get-ChildItem -Recurse *.csproj } `
-Outputs { Join-Path (Get-ChildItem .\src, .\test -Directory | Select-Object -ExpandProperty FullName) -ChildPath "obj\project.assets.json" } `
-Before Build, BuildHost, Test {
exec { & $script:dotnetExe restore }
} Here's the list of file paths generated by the Outputs ScriptBlock:
Though now that I look at this list, one of those files never gets created by the restore operation. That must be why the task always gets run. Is there a way I can get verbose output to see what evaluation the incremental build check used to determine that a task should run? |
No. I thought of such a feature. I was not sure and I am still not sure. Every feature comes with some cost... I will think again, though. |
@daviwil, I am closing this issue, as far as Invoke-Build works as designed. I have opened two new issues related to this discussion
|
@daviwil |
Hey Roman, I'm trying to use incremental builds for the PowerShell Editor Services build script and ran across this error:
Since I'm using
Get-ChildItem
in my Outputs list to get the list of potential outputs, that list will be empty if those output files haven't yet been created. Is it possible that this error could be removed, or is there some other way around it?Thanks!
The text was updated successfully, but these errors were encountered: