MSBuildSdks icon indicating copy to clipboard operation
MSBuildSdks copied to clipboard

Add Artifact file renaming feature

Open MatthieuMEZIL opened this issue 2 years ago • 3 comments

Add Artifact file renaming feature

MatthieuMEZIL avatar Apr 15 '23 06:04 MatthieuMEZIL

@MatthieuMEZIL can you add some examples in the pull request description on how this will work for end users? I'm having trouble picturing how to convey the intent to have files renamed.

jeffkl avatar May 03 '23 16:05 jeffkl

@jeffkl e.g. <Artifact Include="App.config" RenamedFiles="Foo.exe.config" DestinationFolder="$(O)" />

MatthieuMEZIL avatar May 03 '23 21:05 MatthieuMEZIL

@MatthieuMEZIL a lot of people use wildcards when staging artifacts:

<ItemGroup>
  <Artifact Include="MyFolder\MyStuff"
            FileMatch="*.txt *.ini *.xml"
            DestinationFolder="$(ArtifactsPath)" />
</ItemGroup>

If there's more than file found in the bucket, should there be an error? We don't want to copy all files that match to the same destination file.

I think ideally users could supply a transform but that would be very complicated because we'd have to let the user supply a pattern with tokens and get it right:

<ItemGroup>
  <Artifact Include="MyFolder\MyStuff"
            FileMatch="*.txt *.ini *.xml"
            DestinationFolder="$(ArtifactsPath)"
            DestinationFile="$filename$.altered.$extension$" />
</ItemGroup>

Even then, I think there should be an error or warning if the same file was written to the same path more than once. I'm wondering if its better for the build logic to handle this rename and then have Artifacts just stage the outputs from there after the files are already renamed?

jeffkl avatar May 05 '23 15:05 jeffkl