TFS build does not copy Cordova project output

2019-09-02 07:53发布

问题:

I am working on a Cordova project developed with Visual Studio Tools for Apache Cordova CTP 3.1 in Visual Studio 2013 Update 4. I have created a TFS build definition (I'm using TFS 2013) for the project that is able to build the project. I get the correct output, but this output is not copied to the specified dropped location or anywhere else.

I have tried a lot of things and nothing worked. I believe it must be related to the fact that the .jsproj does not define and OutputType or an OutputPath for any configuration.

In the build definition for Staging location in Build defaults I have selected Copy build output to the following drop folder. All I get there is the logs.

See the image below. the src folder contains the sources and after the build the output of the Cordova build (bin and bld). However, I'd expect the content from bin\Android\Release to be copied to the upper level bin folder (as seen in the picture) and eventually on the drop location. This does not happen.

Any help is appreciated.

回答1:

You can use a PowerShell script to get this to work.

$packages = gci $Env:TF_BUILD_SOURCESDIRECTORY -recurse -include $("bin") | ?{ $_.PSIsContainer } | foreach { gci -Path $_.FullName -Recurse -include $("*.apk", "*.ipa", "*.plist", "*.xap") }
foreach ($file in $packages) {
    Copy $file $Env:TF_BUILD_BINARIESDIRECTORY
}
gci $Env:TF_BUILD_SOURCESDIRECTORY -recurse -include $("AppPackages") | ?{ $_.PSIsContainer } | Copy -Destination $Env:TF_BUILD_BINARIESDIRECTORY –Recurse -Force 

Put this in a solution folder in the solution root so that it doesn't get added to the app package and check this in with your solution.

Then in your TFS build definition add a "Post-build script" that points to this script.