Trying to wire custom task to artifact, but "Cannot convert the provided notation"

I have a custom task that produces a file, and I’m trying to declare this as an artifact. Here’s my custom task:

class ConcatFiles extends DefaultTask {
    @InputFiles
    FileCollection files
    @OutputFile
    File target
    @TaskAction
    void concat() {
        files.each { file ->
            target.append(file.getBytes())
        }
    }
}

task buildWindowsInstaller(type: ConcatFiles) {
	files = files('src/installer/native/7zS.sfx', 'src/installer/native/config.txt', build7zaArchive)
    target = file("$buildDir/distributions/setup.exe")
    
    doLast {
    	// some code signing stuff
    }
}

I thought I could wire setup.exe as an artifact. Here’s how I declared it:

artifacts {
	archives buildWindowsInstaller
}

But when I try to run this:

* What went wrong:
A problem occurred evaluating project ':com.elsten.bliss.build.base'.
> Cannot convert the provided notation to an object of type PublishArtifact: task ':com.elsten.bliss.build.base:buildWindowsInstaller'.
  The following types/formats are supported:
    - Instances of PublishArtifact.
    - Instances of AbstractArchiveTask, for example jar..
    - Maps
    - Instances of File.

I thought target was the output, and was an instance of file?

I can use the output from buildWindowsInstaller' as the input to a Copy task in the from attribute.

You will have to explicitly tell Gradle the file to use here. Unfortunately you can only pass a Task instance when that task extends from AbstractArchiveTask. You could simply change your build script like so. This will also instruct Gradle that to publish this artifact it must execute the buildWindowsInstaller task.

artifacts {
    archives(buildWindowsInstaller.target) {
        builtBy buildWindowsInstaller
    }
}

Thanks Mark, this gets it compiling.