I have TFS2008 and have a build running, however, I want to automate the deployment of the build folder and place the build into the inetpub folder it belongs to.
I.E.:
Run Build
After Build, automatically place the new built solution into Inetpub/wwwroot/websitefolder
I have tried xcopy, robocopy and synctoy 2.1 and I cannot get any of them to work.
(xcopy use)
<Exec Command="xcopy $(DropLocation)\$(BuildNumber)\Debug\_PublishedWebsites\IPAMIntranet C:\Inetpub\wwwroot\IPAMOnlineSystem.Test /E " />
(robocopy use)
<Exec Command="ROBOCOPY $(DropLocation)\$(BuildNumber)\Debug\_PublishedWebsites\IPAMIntranet C:\Inetpub\wwwroot\IPAMOnlineSystem.Test /S /XJ /B /R:5" />
(synctoy 2.1 use)
<Exec Command="SyncToyCmd.exe -RIPAMBuildProjectDeploy" />
Can anyone at all please help me with this dilemna?
Thank you in advance
This has been effectively resolved by using MSDeploy.
Related
I am working differentially building a huge monolithic solution that includes about 80 projects. In my build pipeline right now I include a step to build the entire solution. But what I'd like to do is to build the solution but provide conditions as msbuild arguments so that I can exclude some of the projects that might not have any changes associated with them. I already have scripts to go through my commits and realize what changed and which projects need to be built.
I just need a way to send that info to MSBuild so that it does not build all projects everytime. I tried building projects separately but that takes a whole lot more time than just building the solution together.
So, I'm looking for any solutions out there through which I can specify to MSBuild that skip a specific project would help a lot. Thanks much!
I already have scripts to go through my commits and realize what
changed and which projects need to be built.
Since I could get clearly know that which script are you using to realize what changed and which projects need to be built. I am assuming that you are using MSbuildTarget script which in the xx.csproj to do these judgement.
=If I did not have misunderstanding, you can get help from this similar issue (See ilya's answer).
See this document and you'll find the build action is performed by these three targets, BeforeBuild,CoreBuild and AfterBuild. So assuming you have a target to go through my commits and realize what changed and if a project need to be built, you can add script like below to xx.csproj:
<PropertyGroup>
<BuildWrapperDependsOn>$(BuildDependsOn)</BuildWrapperDependsOn>
<BuildDependsOn>CheckIfBuildIsNeeded;BuildWrapper</BuildDependsOn>
</PropertyGroup>
<Target Name="CheckIfBuildIsNeeded">
<!-- Execute command here that checks if proceed with the build and sets the exit code -->
<Exec Command="exit /b 1" WorkingDirectory="$(SourcesPath)" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="ExecExitCode"/>
</Exec>
<Message Text="Exit Code: $(ExecExitCode)" Importance="high" />
<PropertyGroup Condition="'$(ExecExitCode)' == '1'">
<DoBuild>false</DoBuild>
</PropertyGroup>
</Target>
<Target Name="BuildWrapper" Condition=" '$(DoBuild)' != 'false' " DependsOnTargets="$(BuildWrapperDependsOn)" Returns="$(TargetPath)" />
Above is the script from ilys, and hope my description can help you understand it. With this script, when we start a build target, it will firstly run the targets it depends on, so it will run the CheckIfBuildIsNeeded target and BuildWrapper target. And only when the DoBuild property is true, the BuildWrapper will actually execute. And since buildwrapper depends on original $(BuildDependsOn), it will continue the real build process.
The total logic is: Run CheckIfBuildIsNeeded script and output value to indicates whether need to build=>Try to Run BuildWrapper=>IF need to build, then run the real build success(BeforeBuild, Corebuild,Afterbuild), if the value is false, finish the build process. So I think you can do some little changes to this script then it can work for your situation. (Not sure what your script looks like, I can't complete it for you)
And since you have many projects, you don't need to add this script to every project manually. You can create a Directory.Build.props file, copy the script into it, and place the file in solution folder, then it will work for all projects in the solution.
Is it possible to have an optional <PreBuildEvent> in a *.csproj file? I have the following:
<PropertyGroup>
<PreBuildEvent>git rev-parse HEAD >../../git-hash.txt</PreBuildEvent>
</PropertyGroup>
This outputs the latest git hash to a file, which is embedded in the executable elsewhere.
Since I'm a University student, I'm often writing code on the University machines (and not my linux machine at home) which have SVN and not git, causing the build process to fail. Is it possible to make the above <PreBuildEvent /> optional so that if git isn't installed the build process doesn't fail?
Just skipping the build event would leave you with an empty git-hash.txt so that doesn't seem the best idea. Instead you could just try to run the git command, and if it fails write a dummy hash to the file. I don't know the command line syntax to do that (a PreBuildEvent runs under cmd.exe) so here's an msbuild solution. Because of the BeforeTargets="Build" it will run before the build as well.
<Target Name="WriteGitHash" BeforeTargets="Build">
<Exec Command="git --work-tree=$(Repo) --git-dir=$(Repo)\.git rev-parse HEAD 2> NUL" ConsoleToMSBuild="true" IgnoreExitCode="True">
<Output TaskParameter="ConsoleOutput" PropertyName="GitTag" />
</Exec>
<PropertyGroup>
<GitTag Condition="'$(GitTag)' == ''">unknown</GitTag>
</PropertyGroup>
<WriteLinesToFile File="$(Repo)\git-hash.txt" Lines="$(GitTag)" Overwrite="True"/>
</Target>
Some notes:
The 2> NUL redirects standard error to the output so GitTag will be empty in case of an error, in which case it's set to 'unknown'
Relying on the current directory is nearly always a bad idea so specify the directory to run git in explicitly in a property
Same for the output file
I have many projects that I have created a common MSBuild file to run against. I am attempting to integrate PVS Studio's static analysis into the build without having it build a second time. I followed a bit of the documentation on PVS's site, but I must be missing something.
I say that because when I build the PVS does not seem to my triggered/called.
Does anybody have any experience with this and could give me a hand?
Here is the PVS bit of my build file.
<UsingTask TaskName="ProgramVerificationSystems.PVSStudio.PVSStudio"
AssemblyFile="C:\Program Files (x86)\PVS-Studio\PVS-Studio-MSBuild.dll" />
<Target Name="PVSStudioAnalysisBeforeCompile" BeforeTargets="ClCompile">
<Exec Command="echo PVSStudio initiating now."/>
<PVSStudio Condition="'%(ClCompile.ExcludedFromBuild)'!='true'"
Sources="#(ClCompile)"
BeforeClCompile="true"
BuildingInIDE="false"
TrackerLogDirectory="%(ClCompile.TrackerLogDirectory)"
PreprocessorPath="$(VCInstallDir)"
Platform="$(Platform)"
ProjectFullPath="$(MSBuildProjectFullPath)"
SolutionDir="$(SolutionDir)">
<Output TaskParameter="SourcesAfterTlogParsing"
ItemName="CLCompileAfterTlogParsing" />
</PVSStudio>
</Target>
<Target Name="PVSStudioAnalysisAfterCompile" AfterTargets="ClCompile">
<PVSStudio Sources="#(CLCompileAfterTlogParsing)"
BeforeClCompile="false"
BuildingInIDE="$(BuildingInsideVisualStudio)"
PreprocessorPath="$(VCInstallDir)"
OutputFilePath ="$(OutputDir)"
Platform="$(Platform)"
ProjectFullPath="$(MSBuildProjectFullPath)"
SolutionDir="$(SolutionDir)" />
<Exec Command="echo PVSStudio finished"/>
I'm sure you all will need a bit more info to figure this out so let me know what I should get for you.
Thanks,
TBG
You should do one of the following:
If you want analyzer's output to be saved to a file, the you should set BuildingInIDE attribute to false in both tasks, you should also specify a file for the output to be saved to, for example, OutputFilePath = "$(OutputDir)"/pvs.log.
You will be able to view such log from PVS-Studio IDE plug-in / Standalone by opening it as unparsed log.
If you want to build your project from inside Visual Studio and PVS-Studio plug-in to hook up the analyzer results to it output window immediately, then you should set both BuildingInIDE attributes to true (or "$(BuildingInsideVisualStudio)") and enable the MSBuild mode by going to PVS-Studio -> Options -> Specific Analyzer Settings -> MSBuild Output Log Monitoring and set it to true.
Has anyone done this? If so, what tools/techniques/approaches did you use?
Is it possible to do with installing the SQL Business Studio Version of Visual Studio?
Thanks in advance!
Got it folks...
1) Install MSBuild Extensions
2) Created a Build.Xml file as so...
<Project ToolsVersion="3.5" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>
<Target Name="Default">
<PropertyGroup>
<OutputRoot>../../../build-artifacts</OutputRoot>
</PropertyGroup>
<ItemGroup>
<SSISProjectFile Include="SSISProject.dtproj"/>
<SSISProject Include="#(SSISProjectFile)">
<OutputDirectory>$(OutputRoot)</OutputDirectory>
</SSISProject>
</ItemGroup>
<ItemGroup>
<Namespaces Include="Mynamespace">
<Prefix>DTS</Prefix>
<Uri>www.microsoft.com/SqlServer/Dts</Uri>
</Namespaces>
</ItemGroup>
<MSBuild.ExtensionPack.Xml.XmlFile
TaskAction="UpdateElement"
File="EnclarityDataImport.dtsx"
XPath="//DTS:Property[#DTS:Name='ConfigurationString']"
InnerText="$(MSBuildProjectDirectory)\EnclarityDataImport.dtsConfig"
Namespaces="#(Namespaces)"/>
<MSBuild.ExtensionPack.SqlServer.BuildDeploymentManifest InputProject="#(SSISProject)"/>
</Target>
The only trick was the last part of the build here. By default visual studio adds the absolute path to your config and connection string files for your dtsx package. Team City will use these in conjunction with MSBuild extensions to build the package so a local path will break the build because the paths to the build directories in Team City are automatically generated. So using the code above and the $(MSBuildProjectDirectory) you can twiddle the value of the path on your dtsx file so that it points to the path where your compilation is exectuing.
Like booyaa says SSIS projects don't need to be compiled, but what i have done is make the .dtconfigs configurable by the build/deployment process.
I do this so that i can run the packages on deployment in different environments. So the build will copy a template of the dtconfig file.
this contains tokens- $(Servername) $(ConnectionString)
And then i do the replacement on deployment and then execute by wrapping the dtexec in an command.
Not sure about 2012.
VS 2010; TFS 2010; ASP.Net 4.0; Web Deployment Projects 2010;
I am using the build process templates in order to do one-click deploys (for dev and QA only). I want my sites to be pre-compiled. I can do it with the command line, using:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler
-v /site_name
-p "C:\...\site_name"
-f "C:\...\site_name1"
and this works fine if I copy the files over from site_name1 to site_name...
but is there an option in the IDE for this?? It seems really silly to have to do this from the command line. I've read a lot about different options, but none seem applicable to building with the build definitions.
You can do this by adding the following to your .csproj file
<PropertyGroup>
<PrecompileVirtualPath>/whatever</PrecompileVirtualPath>
<PrecompilePhysicalPath>.</PrecompilePhysicalPath>
<PrecompileTargetPath>..\precompiled</PrecompileTargetPath>
<PrecompileForce>true</PrecompileForce>
<PrecompileUpdateable>false</PrecompileUpdateable>
</PropertyGroup>
<Target Name="PrecompileWeb" DependsOnTargets="Build">
<Message Importance="high" Text="Precompiling to $(PrecompileTargetPath)" />
<GetFullPath path="$(PrecompileTargetPath)">
<Output TaskParameter="fullPath" PropertyName="PrecompileTargetFullPath" />
</GetFullPath>
<Message Importance="high" Text="Precompiling to fullpath: $(PrecompileTargetFullPath)" />
<GetFullPath path="$(PrecompilePhysicalPath)">
<Output TaskParameter="fullPath" PropertyName="PrecompilePhysicalFullPath" />
</GetFullPath>
<Message Importance="high" Text="Precompiling from fullpath: $(PrecompilePhysicalFullPath)" />
<AspNetCompiler PhysicalPath="$(PrecompilePhysicalPath)" VirtualPath="$(PrecompileVirtualPath)" TargetPath="$(PrecompileTargetPath)" Debug="true" Force="$(PrecompileForce)" Updateable="$(PrecompileUpdateable)" FixedNames="true" />
Then in TFS2010's default template
your build definition
Process tab
Advanced parameters section
MSBuild Arguments
set /target="PrecompileWeb"
As it currently stands, I can not find any IDE option to pre-compile websites using the build process templates. I would love to be proved wrong, as using the command line aspnet_compiler requires us (in our setup) to crack open the actual build process template, which we are trying to avoid.
I would love to be proved wrong! :)
We have a website that is stored in TFS2010 as a Web application. I use a MSBuild command to deploy from TFS2010. If you open your project in VS2010 Team Explorer you will see there is a "Builds" option. If you add a build and in the process tab use a build argument like ...:/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=RemoteAgent /p:MSDeployServiceUrl=http://111.111.111.111/msdeployagentservice /p:DeployIisAppPath=MySiteNameInIIS /p:UserName=myDomain\BuildUser /p:Password=BuildUserPassword In the Process tab where it says "Items to Build" you just point it to your .sln file (might work with a .cspro but then the syntax changes slightly)
We have a TFS2010 server and I deploy a few of our sites to a dev, qa, pre-production or production IIS server. I do unit testing on the dev build and if the test fail then I do not deploy.
The MSBuild command does the pre-compile, would that work for you?
A setting for precompiling has been added. The following works in Visual Studio 2015
Open a solution
Right click on the project
Select "Publish..."
Go to settings, expand "File
Check "Precompile during Publishing"