<commit_before>[CmdletBinding(DefaultParameterSetName = 'None')]
param
(
    [String] [Parameter(Mandatory = $true)]
    $CopyRoot,

    [String] [Parameter(Mandatory = $true)]
    $Contents,

    [String] [Parameter(Mandatory = $true)]
    $ArtifactName,

    [String] [Parameter(Mandatory = $true)]
    $ArtifactType,

    [String] [Parameter(Mandatory = $false)]
    $TargetPath
)

Write-Host "Entering script Publish-BuildArtifacts.ps1"
Write-Host "CopyRoot = $CopyRoot"
Write-Host "Contents = $Contents"
Write-Host "ArtifactName = $ArtifactName"
Write-Host "ArtifactType = $ArtifactType"

# Import the Task.Internal dll that has all the cmdlets we need for Build
import-module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"

$buildId = Get-TaskVariable $distributedTaskContext "build.buildId"
$teamProjectId = Get-TaskVariable $distributedTaskContext "system.teamProjectId"
$stagingFolder = Get-TaskVariable $distributedTaskContext "build.artifactstagingdirectory"

# gather files into staging folder
Write-Host "Preparing artifact content in staging folder $stagingFolder..."
$artifactStagingFolder = Copy-BuildArtifact $distributedTaskContext $CopyRoot $stagingFolder $ArtifactName $Contents

# copy staging folder to artifact location
if ($ArtifactType -ieq "container")
{
    Publish-BuildArtifact $ArtifactName $artifactStagingFolder
}
elseif ($ArtifactType -ieq "filepath")
{
    if ((Test-Path $TargetPath) -eq 0)
    {
        Write-Host "Creating target path $TargetPath..."
        MD $TargetPath
    }

    Write-Host "Copying artifact content to $TargetPath..."
    Copy-Item $artifactStagingFolder $TargetPath -Recurse -Force

    Add-BuildArtifactLink $ArtifactName $ArtifactType $TargetPath
}

Write-Host "Leaving script Publish-BuildArtifacts.ps1"<commit_msg>1) Added warning for invalid UNC path format. 2) Call resx helper for user facing strings.<commit_after>[CmdletBinding(DefaultParameterSetName = 'None')]
param
(
    [String] [Parameter(Mandatory = $true)]
    $CopyRoot,

    [String] [Parameter(Mandatory = $true)]
    $Contents,

    [String] [Parameter(Mandatory = $true)]
    $ArtifactName,

    [String] [Parameter(Mandatory = $true)]
    $ArtifactType,

    [String] [Parameter(Mandatory = $false)]
    $TargetPath
)

Write-Verbose "Entering script Publish-BuildArtifacts.ps1"
Write-Verbose "CopyRoot = $CopyRoot"
Write-Verbose "Contents = $Contents"
Write-Verbose "ArtifactName = $ArtifactName"
Write-Verbose "ArtifactType = $ArtifactType"
Write-Verbose "TargetPath = $TargetPath"

# Import the Task.Internal dll that has all the cmdlets we need for Build
import-module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"

$buildId = Get-TaskVariable $distributedTaskContext "build.buildId"
$teamProjectId = Get-TaskVariable $distributedTaskContext "system.teamProjectId"
$stagingFolder = Get-TaskVariable $distributedTaskContext "build.artifactstagingdirectory"

# gather files into staging folder
Write-Host (Get-LocalizedString -Key "Preparing artifact content in staging folder {0}..." -ArgumentList $stagingFolder)
$artifactStagingFolder = Copy-BuildArtifact $distributedTaskContext $CopyRoot $stagingFolder $ArtifactName $Contents

# copy staging folder to artifact location
if ($ArtifactType -ieq "container")
{
    Publish-BuildArtifact $ArtifactName $artifactStagingFolder
}
elseif ($ArtifactType -ieq "filepath")
{
    if ("$TargetPath".StartsWith('//'))
    {
        Write-Warning (Get-LocalizedString -Key 'UNC paths must start with ''\\''. Invalid UNC path: {0}' -ArgumentList $TargetPath)
    }

    if ((Test-Path $TargetPath) -eq 0)
    {
        Write-Host (Get-LocalizedString -Key 'Creating target path {0}...' -ArgumentList $TargetPath)
        MD $TargetPath
    }

    Write-Host (Get-LocalizedString -Key 'Copying artifact content to {0}...' -ArgumentList $TargetPath)
    Copy-Item $artifactStagingFolder $TargetPath -Recurse -Force

    Add-BuildArtifactLink $ArtifactName $ArtifactType $TargetPath
}

Write-Verbose "Leaving script Publish-BuildArtifacts.ps1"
{'fraction_non_alphanumeric': 0.10973495169680456, 'fraction_numerical': 0.002972504334902155, 'mean_word_length': 4.852173913043479, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7386824', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1203, 'n_words': 313}