I'm trying to create a command line MSBUILD publish on a Jenkins server with a PreBuildEvent to do a bower install. I already tried several options (see below) but the command line output just says build completed without executing the PreBuildSteps and without showing any errors.
Test1
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>URL</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeFoldersFromDeployment>bower_components</ExcludeFoldersFromDeployment>
<ExcludeFilesFromDeployment>bower.json</ExcludeFilesFromDeployment>
</PropertyGroup>
<Target Name="BeforeBuild">
<Exec Command="bower-installer -silent" />
</Target>
</Project>
Test2
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<PreBuildEvent>
<Command>bower-installer -silent</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<PropertyGroup>
<PreBuildEventUseInBuild>true</PreBuildEventUseInBuild>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>URL</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeFoldersFromDeployment>bower_components</ExcludeFoldersFromDeployment>
<ExcludeFilesFromDeployment>bower.json</ExcludeFilesFromDeployment>
</PropertyGroup>
</Project>
The command I'm executing is the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild "<PATH>\website.publishproj" /p:DeployOnBuild=true /p:PublishProfile="<PROFILE>" /p:VisualStudioVersion=14.0
Any help anyone??
I found the solution...
All the files were in the correct place and the import statements were correctly defined, but if you want to execute the MSBUILD from command line, you have to add some extra parameters.
.pubxml
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>URL</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeFoldersFromDeployment>bower_components</ExcludeFoldersFromDeployment>
<ExcludeFilesFromDeployment>bower.json</ExcludeFilesFromDeployment>
</PropertyGroup>
<Target Name="BeforeBuild">
<Exec Command="bower-installer -silent" />
</Target>
</Project>
Command line
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild "<PATH>\website.publishproj"
/t:BeforeBuild;Build /p:DeployOnBuild=true /p:PublishProfile="<PROFILE>"
/p:VisualStudioVersion=14.0
The trick was to add the /t:<Target Name>;Build
(don't forget to add the build are else it will only execute the specified target).