Can anyone please help me in converting the below nant script to MsBuild Script?
http://localhost//Tupe path="${triad_web_src_code.dir}\T.csproj" />
If it is not a web solution then I need not map the solution & the msbuild could be like this :
But this is not working for Web project. So please help...
Microsoft.Sdc.Tasks.Web.WebSite.CreateVirtualDirectory
VirtualDirectoryName="SampleVirtualDirectory"
Path="$(PhysicalOutputPath)"
WebSiteName="$(DefaultWebSiteName)" AppCreate="True" /
http://www.dotnetspider.com/resources/29209-MSBuild-Script-Sample-for-deployment-web.aspx
Should be what your looking for
An alternative the the approaches listed above is to create use Web Deployment Projects (2005 2008) for this. They support creating virtual directories as well a pre-compiliation out of the box.
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build
If you need to create both a virtual directory and an IIS application pool together you can do the following:
<Web.AppPool.Create
AppPoolName ="$(AppPoolName)"
IdentityType="NetworkService"/>
<Web.WebSite.CreateVirtualDirectory
VirtualDirectoryName="$(WebServiceVirtualDirectoryName)"
Path="$(WebServiceVirtualDirectoryPath)"
AppPoolId="$(AppPoolName)"
WebSiteName="$(WebServiceSiteName)"
Condition="!Exists('$(WebServiceVirtualDirectoryName)')"/>
An alternative could be MSBuild Community Tasks it has the WebDirectoryCreate task that accomplishes the same thing.
Related
I'm trying to use MSBuild to create a target that will create an installer with InstallShield 2012. I'm having difficultly understanding how to access InstallShield. I ran across this mentioning an InstallShield task but I'm not sure how to get access to it. I think I need a UsingTask directive, but not sure what to import. Can someone give me a pointer on how to get this going? Thanks.
You need to import the targets file. Took me a while to figure that out as well since it's in the msbuild extensions directory together with a dll. Here's a basic sample of how to use it (note this is for 2012Spring but you get the idea):
<Import Project="$(MSBuildExtensionsPath32)\InstallShield\2012Spring\InstallShield.targets" />
<Target Name="BuildInstaller">
<InstallShield.Tasks.InstallShield
Project="/path/to/my.ism"
ProductConfiguration="Package"
ReleaseConfiguration="MSI" />
</Target>
Btw if this doesn't work out for some reason, you can always invoke ISCmdBld.exe in an Exec task, it will do the job just as fine.
InstallShield provides Visual Studio integration. When you create an InstallShield project in VS it creates a project file (.ISPROJ) which imports the InstallShield.targets file for that version of InstallShield. The project file contains plenty of examples on how to build a particular configuration and pass in such things as merge module path, properties, path variable overrides and so on.
Please note that building InstallShield requires the x86 MSBuild platform due to COM components.
I just downloaded TeamCity 7 today and decided to get it up and running for my Azure solution. I am not trying to do anything fancy (yet) and started with a very basic command line build:
msbuild /t:Publish /p:Configuration=Release;TargetProfile=Production;PublishDir=S:\HoursTracker\Deployments
This builds successfully and produces a package that looks like this*:
I then attempted to configure TeamCity in an identical fashion:
This builds successfully and produces a package that looks like this*:
What I don't understand is why there is such a huge discrepancy in the size of the MVC project. Publishing directly from Visual Studio produces the exact same result as my MSBuild command so I'm convinced that TeamCity is the odd man out. Since I assume TeamCity is not broken, can someone please educate me on how to properly configure it so that I get the expected output?
*I have renamed the package files with .zip so that the details were viewable for this post.
Ming's answer helped me solve the mystery. After inspecting the contents of the zip files, I discovered the difference was that my MSBuild package contained bin and obj folders and the TeamCity package did not.
After making this discovery, I realized that I could specify multiple targets to MSBuild and prepended "Clean" to my targets switch like so:
msbuild /t:Clean;Publish /p:Configuration=Release;TargetProfile=Production;PublishDir=S:\HoursTracker\Deployments
As expected, this removed those folders. So apparently, TeamCity specifies "Clean" implicitly for you. Mystery solved.
Windows Azure packages may be larger than we expect. You can rename the cssx file to zip and you will find out what’s inside the package. In addition to the web application’s usual files, there’re a bunch of Windows Azure files. For example, if you enable diagnostics, you will see a diagnostics folder, where you’ll find files used by Windows Azure diagnostics runtime.
Best Regards,
Ming Xu.
Why you specified x64 for msbuild runner? Try selecting tools version as well. You have not specified /p:Platform parameter. Does publish task involve rebuild?
TeamCity starts msbuild with number of /p: parameters taken from " properties and environment variables " section, plus some well-known parameters like configuration name or project name.
I am looking for a very simple example that shows what exactly is and how to use the MSBuild Extension Pack: http://msbuildextensionpack.codeplex.com/ I just cannot find anything for a real beginner. Thank you.
Go through these Links,
They would be very useful, I figured out how to use MSBuildCommunityTasks through them,
How do I import the msbuildcommunitytasks project from another msbuild project with a relative file path?
Msbuild and SVN update
Also,
Example
<SvnUpdate
Username="$(CommitUser)"
Password="$(CommitPassword)"
LocalPath="$(ProjectDir)">
</SvnUpdate>
Its just what you use on the Command Line.
As part of our Continuous Integration builds, I'd like the build to fail if a Visual Studio solution is using two different versions of the same dll. We are using Jenkins for CI and MSBuild.exe to build our product.
I know that this can be accomplished via C# code, but I'm trying to avoid that. I'd prefer to use something built into MSBuild or MSBuild Community Tasks or a built in command line executable like FC.exe. I've looked at FC.exe and it outputs text that says
FC: no differences encountered
and I suppose I can direct the output to a file and then parse that file, but that seems hacky at best.
Is there an elegant way to do this?
Nevermind...I just executed FC.exe within MSBuild and I noticed that it returns an error code of 1 when the files do not match. Problem solved!
You could invoke powershell via MSBuild (I think the community tasks have a cmdlet execution task) and leverage the Compare-Object cmdlet.
http://technet.microsoft.com/en-us/library/ee156812.aspx
Jenkins has a PowerShell module as well that you could use.
I have an asp.net mvc application that I am publishing with Publish feature of Visual Studio and I have a custom MSBuild task that needs the directory that I am publishing to so it knows where to copy some custom build files to...
I've tried $(OutDir), $(PublishDirectory) and a bunch of others... how do I get this path?
For me what worked was:
$(PublishUrl)
And i got what i was needing: My publish directory.
Thanks.
I was able to combine $(ProjectDir) & $(PublishDir) to get the publishing folder. However, I was publishing SharePoint app but I think it should work for other cases as well.
For example to call a program
<Exec Command=""$(ProjectDir)\app.exe" "$(ProjectDir)$(PublishDir) ""/>
You should be able to use the PackageArchiveRootDir property to resolve that. The default value for that is obj\Debug\Package. So if you need the full path you just combine the MSBuildProjectDirectory with the PackageArchiveRootDir like: $(MSBuildProjectDirectory)\$(PackageArchiveRootDir).