When having the SharePoint 15 and 16 libraries installed, which is a normal case if you update Visual Studio 2013, the script fails. I would like to suggest updating the function function CopyFileFromFolder([string]$Path, [switch]$Recurse) to deal with this in a better way than just aborting the script. I.e. rewrite it to this and all will work fine:
```
# Copies file from the specified path or its sub-directory to the $FilesPath
function CopyFileFromFolder([string]$Path, [switch]$Recurse) {
process {
$FileName = $_
if (!$Recurse) {
$FileInfo = [System.IO.FileInfo]$(Join-Path $Path $FileName)
} else {
$FileInfo = Get-ChildItem $Path -Recurse | Where { $_.Name -eq $FileName }
}
if (!$FileInfo) {
WriteWarning """$FileName"" was not found in $Path"
return
}
if ($FileInfo -is [array]) {
WriteWarning "Multiple instances of $FileName were found in $Path"
$FileInfo = $FileInfo[0]
}
Copy-Item $FileInfo.FullName $FilesPath -Recurse -Force
WriteText """$($FileInfo.FullName)"" [was copied to ==>] ""$FilesPath"""
}
}
```
Comments: ** Comment from web user: rroman81 **
```
# Copies file from the specified path or its sub-directory to the $FilesPath
function CopyFileFromFolder([string]$Path, [switch]$Recurse) {
process {
$FileName = $_
if (!$Recurse) {
$FileInfo = [System.IO.FileInfo]$(Join-Path $Path $FileName)
} else {
$FileInfo = Get-ChildItem $Path -Recurse | Where { $_.Name -eq $FileName }
}
if (!$FileInfo) {
WriteWarning """$FileName"" was not found in $Path"
return
}
if ($FileInfo -is [array]) {
WriteWarning "Multiple instances of $FileName were found in $Path"
$FileInfo = $FileInfo[0]
}
Copy-Item $FileInfo.FullName $FilesPath -Recurse -Force
WriteText """$($FileInfo.FullName)"" [was copied to ==>] ""$FilesPath"""
}
}
```
Comments: ** Comment from web user: rroman81 **
This is definitely an issue. I think the overall collection and installation process needs to be expanded to accomodate both the O365 and SP2013 runtimes. I will be refactoring script to allow the SP2013 (as to keep already existing v15 semantics) short-term. However, i think long term, the build server needs to be able to build for both runtimes seemlessly.