I am attempting to merge a Visual Studio 2010 project to 2012. The 2010 solution had a deployment project which output can be replicated by publishing in 2012. Our build script looking something like this:
<target name="buildSolution">
<delete file="${BuildRootFolder}\build.log" />
<exec program="devenv.exe" verbose="true" timeout="2400000"
commandline='/out build.log ${BuildRootFolder}\Solution.sln /Build "Release" /deploy Solution'
basedir="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE">
<environment>
<variable name="PATH"
value="blah blah....">
</environment>
</exec>
</target>
How do I update this to Publish one of the projects in that solution using the publishing profile I defined?
Forget devenv and use msbuild.
<property name="MSBuildPath" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"/>
<target name="buildSolution" depends="clean">
<exec program="${MSBuildPath}">
<arg line='"${BuildRootFolder}\Solution.sln"' />
<arg line='/property:Configuration="Release";DeployOnBuild=true;PublishProfile=Deployment' />
<arg value="/target:Build" />
<arg value="/verbosity:normal" />
<arg value="/nologo" />
</exec>
</target>
Related
Anyone knows if i could determine if AfterClean task was executed in context of Rebuild.
I am only intrested to execute my task if Clean is executed explicitly from project context menu.
<Target Name="MyTask" AfterTargets="AfterClean">
<Message Text="Removing file: cache.data" Importance="high" />
<Exec Command="del /S cache.data" ></Exec>
</Target>
found answer myself, there may be a better way.
<Target Name="BuildExecutedFlag" BeforeTargets="BeforeRebuild" >
<CreateProperty Value="1">
<Output
TaskParameter="Value"
PropertyName="WasBuildExecuted" />
</CreateProperty>
</Target>
<Target Name="MyTask" AfterTargets="AfterClean" Condition="'$(WasBuildExecuted)' != '1'">
<Message Text="Removing file: cache.data" Importance="high" />
<Exec Command="del /S cache.data" ></Exec>
</Target>
I need to tie together a bunch of steps which include building solutions, projects and running .cmd files using a custom MSBuild file.
My first pass at this is below:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<ItemGroup>
<ProjectsToBuild Include="..\Hosts\solution1.sln"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\solution2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="helper1.csproj"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\Sandboxes\helper2.sln"></ProjectsToBuild>
<Exec Include="" Command="CALL GetFiles.cmd"/>
<ProjectsToBuild Include="wix\proc\prod.wixproj"></ProjectsToBuild>
<Exec Command="CALL final.cmd"/>
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="#(ProjectsToBuild)" Targets="Build">
<Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>
<Message Text="#ProjectOutputs"/>
</Target>
</Project>
This resulted in an error since the Exec element is in the wrong place.
Basically, I need to build solution1.sln, solution2.sln,helper1.csproj and helper2.sln (in sequence), then, run the file GetFiles.cmd, then build prod.wixproj followed by running the final.cmd file.
I have looked at MSDN (here, here, here), a blog, and browsed through various stackoverflow questions (including this, this, this, this), but none of them quite address what I am trying to do. This is the first time I have ever worked with MSBuild, so it is possible I may have missed something. Will appreciate any pointers...
Since an ItemGroup node can be a child of a Target node, break down those ItemGroup members into separate targets, then use the DefaultTargets attribute to control the sequence in which those are built.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Target1;Target2;Target3" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5" >
<Target Name="Target1">
<Message Text="Target 1" />
</Target>
<Target Name="Target2">
<Message Text="Target 2" />
</Target>
<Target Name="Target3">
<Message Text="Target 3" />
</Target>
</Project>
The build projects are already in the correct order see:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<ItemGroup>
<ProjectsToBuild Include="..\Hosts\solution1.sln"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\solution2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="helper1.csproj"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\Sandboxes\helper2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="wix\proc\prod.wixproj"></ProjectsToBuild>
</ItemGroup>
<Target Name="Build">
<Exec Command="CALL GetFiles.cmd"/>
<Message Text="Build order: %(ProjectsToBuild.Identity)"/>
<MSBuild Projects="#(ProjectsToBuild)" Targets="Build">
<Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>
<Message Text="#(ProjectOutputs)"/>
<<Exec Command="CALL final.cmd"/>
</Target>
</Project>
At the start the order of the itemgroup is displayed:
Project "C:\Test\Testcode\build\testcode.msbuild" on node 1 (default targets).
Build:
Build order: ..\Hosts\solution1.sln
Build order: ....\solution2.sln
Build order: helper1.csproj
Build order: ....\Sandboxes\helper2.sln
Build order: wix\proc\prod.wixproj
All done.
I'm trying to Minify Javascript and CSS using AjaxMin when I deploy using a Web Deploy Publish Profile. Here is what I have in the project file:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\AjaxMin.tasks" />
<PropertyGroup>
<ResGenDependsOn>
MinifyJavascriptAndCss;
$(ResGenDependsOn);
</ResGenDependsOn>
</PropertyGroup>
<Target Name="MinifyJavascriptAndCss"
Condition=" '$(ConfigurationName)'=='Release' ">
<ItemGroup>
<JS Include="$(_PackageTempDir)\**\*.js"
Exclude="$(_PackageTempDir)\**\*.min.js;Scripts\*.js" />
</ItemGroup>
<ItemGroup>
<CSS
Include="$(_PackageTempDir)\**\*.css"
Exclude="$(_PackageTempDir)\**\*.min.css" />
</ItemGroup>
<Message Text="Compressing JavaScript and CSS files into $(_PackageTempDir)"
Importance="high" />
<AjaxMin JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$"
JsTargetExtension=".min.js" CssSourceFiles="#(CSS)"
CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
</Target>
If I watch the output directory I can see that the files are minified as the min.* files appear, but when the package file is deployed, they are not included.
How do I force the minified files to be included in the publish package?
It worked for me in VS2010, but does nothing with VS2012...
<!-- Use AjaxMinifier from Libs folder in this project -->
<UsingTask TaskName="AjaxMin" AssemblyFile="$(MSBuildProjectLocation)Libs\AjaxMinTask.dll" />
<!-- This target will run after publish web in Release mode -->
<Target Name="MinifyJavaScriptAndCSS" AfterTargets="CopyAllFilesToSingleFolderForPackage" Condition="'$(Configuration)'=='Release'">
<ItemGroup>
<!-- Every .js file (exclude *.min.js and *.vsdoc.js files) -->
<JS Include="$(_PackageTempDir)\**\*.js" Exclude="$(_PackageTempDir)\**\*.min.js;$(_PackageTempDir)\**\*vsdoc.js" />
<!-- Every .css file (exclude *.min.css files) -->
<CSS Include="$(_PackageTempDir)\**\*.css" Exclude="$(_PackageTempDir)\**\*.min.css" />
</ItemGroup>
<!-- Log in output build window -->
<AjaxMin JsKnownGlobalNames="jQuery,$" JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js" CssSourceFiles="#(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".css" />
<!-- Log in output build window -->
<Message Text="[pcv] $(MSBuildProjectName) -> Minified: #(JS)" Importance="high" />
<Message Text="[pcv] $(MSBuildProjectName) -> Minified: #(CSS)" Importance="high" />
</Target>
I faced the same problem and successfully resolved it. There is one easy way to do this task.
Set the Build Action of original CSS/JS files to None and set the Build Action of minify files to Content. Now when you build the project then only minified css/java script files will come.
I'm using VS2012, and this worked for me
<!--<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\AjaxMin.targets" />-->
<UsingTask TaskName="AjaxMin" AssemblyFile="$(MSBuildProjectDirectory)\..\packages\AjaxMin.5.14.5506.26202\tools\net40\AjaxMinTask.dll" />
<Target Name="MinifyJsAndCss" AfterTargets="CopyAllFilesToSingleFolderForPackage" >
<ItemGroup>
<JS Include="$(_PackageTempDir)\App_Scripts\**\*.js" Exclude="$(_PackageTempDir)\**\*.min.js" />
<CSS Include="$(_PackageTempDir)\**\*.css" Exclude="$(_PackageTempDir)\**\*.min.css" />
</ItemGroup>
<Message Text="Compressing JavaScript and CSS files...(to edit this feature, unload the project, right click it ->edit -> search for 'AjaxMin' bottom of the xml)" Importance="high" />
<AjaxMin JsSourceFiles="#(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js" CssSourceFiles="#(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
</Target>
On my development machine I installed VSeWSS 1.3 and configured the local IIS 6 so that I can build my SharePoint project and deploy the generated WSP file to the local machine. The WSP file is generated by the Packaging step, which I can successfully install on other machines.
Now I have to migrate my project to our build machine which currently does not have SharePoint installed and is not configured for VSeWSS (no VSeWSS web service endpoint). Is there a way to automate the building of the WSP file without the need to configure IIS on the build machine for use with SharePoint and VSeWSS?
Some of the books describe the manual step of using MakeCab.exe and defining a DDF file, but I don't see any DDF file generated by VSeWSS (is it maybe generated in a TEMP folder which I could use to configure my automated build process?).
I just faced the same problem. I opted for another tool for developing the whole solution: I found WSPBuilder much cleaner and less intrusive. It also can be used from the Command line, which is great for Build files.
I modified some Nant scripts created by Bil Simser in order to compile and deploy the project and move the code from VSeWSS to WSPBuilder. It works like a charm either on my machine or on the build machine.
You can find WSPBuilder on http://www.Codeplex.com, and these targets need nantContrib (on www.tigris.org) to work.
Here are some of the targets I'm using:
<target name="build" depends="compile">
<copy todir="${build.dir}\12\">
<fileset basedir="${sharepoint.dir}\12">
<include name="**/*"/>
</fileset>
</copy>
<copy
file="${sharepoint.dir}\solutionid.txt"
tofile="${build.dir}\solutionid.txt"
/>
<call target="buildsolutionfile" />
</target>
<target name="buildsolutionfile">
<exec program="${wspbuilder.exe}" workingdir="${build.dir}">
<arg value="-BuildDDF"/>
<arg value="${debug}"/>
<arg value="-Cleanup"/>
<arg value="false"/>
<arg value="-FolderDestination"/>
<arg value="${build.dir}"/>
<arg value="-Outputpath"/>
<arg value="${build.dir}"/>
<arg value="-TraceLevel"/>
<arg value="verbose"/>
</exec>
<copy
file="${build.dir}\${package.file}"
tofile="${solution.dir}\${package.file}"/>
</target>
<target name="addsolution">
<exec program="${stsadm.exe}" verbose="${verbose}">
<arg value="-o" />
<arg value="addsolution" />
<arg value="-filename" />
<arg value="${solution.dir}\${package.file}" />
</exec>
<call target="spwait" />
</target>
<target name="spwait" description="Waits for the timer job to complete.">
<exec program="${stsadm.exe}" verbose="${verbose}">
<arg value="-o" />
<arg value="execadmsvcjobs" />
</exec>
</target>
<target name="app.pool.reset" description="Resets Sharepoint's application pool.">
<iisapppool action="Restart" pool="${apppool}" server="${server}" />
</target>
<target name="deploysolution" depends="addsolution">
<exec program="${stsadm.exe}" workingdir="${build.dir}" verbose="${verbose}">
<arg value="-o" />
<arg value="deploysolution" />
<arg value="-name" />
<arg value="${package.file}" />
<arg value="-immediate" />
<arg value="-allowgacdeployment" />
<arg value="-allcontenturls" />
<arg value="-force" />
</exec>
<call target="spwait" />
<call target="app.pool.reset" />
</target>
Good day.
I'm trying to deploy a web application using NAnt. It is current zipped using the NAnt ZIP task.
I can try calling MSDeploy from NAnt but I don't think MSDeploy was written for such deployments.
I can also try using NAnt task.
Does anybody have suggestions as to what approach can save me the most time?
Using the aspnet compiler is the simplest way and gets you access to all cl arguments which is not available on nant tasks. Not sure why it's so.
Here's what I do
<property name="aspnetcomplier" value="C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe" />
<target name="deploy">
<mkdir dir="${output.dir}" />
<exec program="${aspnetcomplier}">
<arg value="-v" />
<arg value="/trunk" />
<arg value="-p" />
<arg value="${source.dir}\Root" />
<arg value="-f" />
<arg value="${output.dir}" />
</exec>
</target
Nothing complicated.Works like a charm.
P.S. Dont forget to do a iisreset /stop and /start
<target name="stop.iis" >
<servicecontroller action="Stop" service="w3svc" timeout="10000" verbose="true" />
</target>
<target name="start.iis" >
<servicecontroller action="Start" service="w3svc" timeout="10000" verbose="true" />
</target>