I am trying to run sonar with my 2 project but in Sonar web i see only one project. Each time when i run sonar its deleting the existing content.
I have removed sonar?create=true from the database connection but still its giving same issue.
I am not sure wheather the database is deleted each time or the sonar is letting to create only one project
You need to have different project keys in your Ant tasks for each project, even if the projects have different names.
The sample ant tasks use org.example:example as the project key, and if you simply copied the sample ant tasks then you probably are using the same key for both projects.
Check over here:docs.codehaus
<sonar:sonar workingDir="..." serverUrl="...">
<project key="org.example:example" version="0.1-SNAPSHOT">
<property name="sonar.dynamicAnalysis" value="false"/>
<sources>
<path location="..."/>
</sources>
</project>
</sonar:sonar>
It sounds like the 2 projects may have the same sonar project name? And one project ist overwriting the other.
And you may want to consider to use a real database(free oracle db or something similar). The integrated one is quite slow and is officially not supported when upgrading later.
Related
We have several .exe projects in our solution. What we are trying to achieve is when the project is built using TFS Team Build, we want MSBuild to create a ClickOnce file in the output folder. This was fairly easy to do: I simply added Publish to the DefaultTargets property of my project:
<Project DefaultTargets="Publish;Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
...
</Project>
This works, however, the ClickOnce application is created even when the project is built locally (e.g. in Debug mode). Is there a way to specify a condition so that Publish is invoked only when the condition is true? I tried to add a a new Target like this:
<Target Condition="$(TeamBuildOutDir) != ''" Name="Publish" />
But this doesn't work. I believe I need additional properties in my target tag to let the MSBuild know that I want a ClickOnce target on $(TeamBuildOutDir) != '', but I'm not sure how to do that. Any help is appreciated.
Edit
I tried this (without Condition="$(TeamBuildOutDir) != ''") just to see if it would work locally:
<Target Name="AfterBuild">
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="Publish"
Properties="PublishDir=C:\ClickOnce"/>
</Target>
However, I'm getting the following error:
There is a circular dependency in the target dependency graph involving target "AfterBuild"
But there is NO circular dependency in the project! The project builds just fine without this Target tag. I'm really confused.
What about using the BuildingInsideVisualStudio property to determine when to call publish?
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.package.projectfileconstants.buildinginsidevisualstudio(v=vs.80).aspx
I'm working within a large build system that uses Ant/Ivy. I try to use a predefined ant task that uses ivy:publish ant task and get this error:
impossible to publish artifacts for com.company.project1.proj1#MySupportJar;working#server1: java.io.FileNotFoundException: /path_to/ivy-repository/com.company.project1.proj1/MySupportJar/5.1.3.part/MySupportJar-5.1.3.jar (No such file or directory)
The directory in the error message exists up to the version number part (5.1.3.part).
I am new to Ivy but think I get the basics of how it works. I can not find much on the exact meaning of this error so if someone could help or point me to an explanation I think I could resolve the issue from there.
Ant target
<target name="publish-shared" depends="ivyInit, resolve"
description="Publish to the shared repository">
<ivy:publish pubrevision="5.1.3"
resolver="shared"
pubdate="${timestamp}"
forcedeliver="true"
update="true"
conf="distro, docs">
<artifacts pattern="dist/[artifact].[ext]"/>
</ivy:publish>
</target>
Ivy file snippet
<publications>
<artifact name="MySupportJar" type="jar" conf="distro" />
<artifact name="MySupportJar-source" type="source" ext="jar" conf="docs" />
</publications>
Thanks.
Thanks for all the suggestions. Turns out to be a simple solution that I was not looking for.
The problem was permissions at /path_to/ivy-repository/com.company.project1. I did not have write permission. The .part file is a temporary file written by Ivy. Ivy could not write the temporary file so when it got to reading the file it failed to find it.
I'm answering this so that it might help someone later.
Thanks.
I'm fairly new to Ant with Ivy too. What I've done is combine a local Maven repository (Artifactory), with Jenkins as a continuous integration server. When we build a jar, I also produce the Maven pom.xml with it. Then, I use the mvn deploy:file command to deploy the desired build to our Maven repository.
The developer manually deploys the jar to our Maven repository via the Promoted Build plugin to Jenkins. The developer selects the build to deploy to Maven, and then pretty much presses a button, and that build will be deployed.
I actually produce two pomswith each build. One ispom.xmland the other ispom-snapshot.xml`. We deploy the snapshot with each build, so other developers can use the latest jar instead of the officially deployed one. I've put the whole thing in github if you're interested.
The only decent Ant/Ivy documentation I've seen is Manning's Ant in Action by Steve Loughram. If it wasn't for that, I probably would have never even tried Ant with Ivy. The online Ant/Ivy documentation at Apache is just plain awful.
I've looked over what you have. I suspect it might be an issue with your ivy-settings.xml file. Somewhere, it's getting the part string as the valid location for publishing the file. Otherwise, I have no idea.
As I said, we use a Maven repository for our site repository, and then use Maven to actually deploy the jars to the repository. I simply found that much easier to do it that way than to figure out how to do this in pure Ivy. Besides, it also means that our Maven projects can also use the jars from our Ant/Ivy projects.
I've tried a number of different configurations with this and I haven't achieved my result.
TL;DR
I'm trying to add config transforms into my build process and am looking for the right way to do it from MSBuild so that it shows up in my deployments via MSDeploy.
Background
I have an WebApp (MVC3), a Core app (CS Class Lib), and two test class libs, one for each.
I have a build script in my solution that uses MSBuild to compile.
One of those MSBuild targets deploys to an IIS server using MSDeploy
This process is working so far both manually and via CruiseControl.NET
Goal
I would like to add Web.Config transforms to this process. I figured I would do something simple at first, like an app setting called "PEAppsEnvironmentName", which I would make Dev, Test, or Prod based on the current environment.
Theory So Far
To me, it appears that when packaging with MSDeploy, I'm not transforming the config file.
When I run MSBuild with the DeployOnBuild option set to true, it creates another package that has the appropriately transformed config. It just seems like somehow I can't get it all to match up. The end result is that the web page displays "None" (the initial setting) instead of the transformed "Development" string.
I think if I could find out how to use MSDeploy during the packaging phase to transform the MSConfig, I'd be good to go.
Code
My web.config file
<appSettings>
<add key ="PEAppsEnvironmentName" value="None"/>
...
</appSettings>
My Web.Dev.config file
<appSettings>
<add key ="PEAppsEnvironmentName" xdt:Transform="Replace" xdt:Locator="Match(key)" value="Development" />
</appSettings>
My MSBuild Targets
Property group showing default config is "Dev"
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Dev</Configuration>
</PropertyGroup>
My MSBuild "Compile" Target
<Target Name="Compile" DependsOnTargets="Init">
<MSBuild Projects="#(SolutionFile)" Targets="Rebuild" Properties="OutDir=%(BuildArtifacts.FullPath);DeployOnBuild=True"/>
</Target>
My MSBuild "Package" Target
<Target Name="Package" DependsOnTargets="Compile;Test">
<PropertyGroup>
<PackageDir>%(PackageFile.RootDir)%(PackageFile.Directory)</PackageDir>
<Source>%(WebSite.FullPath)</Source>
<Destination>%(PackageFile.FullPath)</Destination>
</PropertyGroup>
<MakeDir Directories="$(PackageDir)"/>
<Exec Command='"#(MSDeploy)" -verb:sync -source:iisApp="$(Source)" -dest:package="$(Destination)" '/>
</Target>
My MSBuild "Deploy" Target
(scrubbed for PWs, etc.)
<Target Name='Deploy' DependsOnTargets='Package'>
<PropertyGroup>
<Source>%(PackageFile.FullPath)</Source>
</PropertyGroup>
<Exec Command ='"#(MsDeploy)" -verb:sync -source:package="$(Source)" -dest:iisApp=PEApps,computerName=$(WebServerName),username=[User],password=[Password]'/>
</Target>
There was a lot to this question, I'm not sure if I'm fully on the same page as you but I'll summarize my impression of what you are asking. You have an existing web project which is in a solution with other projects. You need to be able to package the web project so that you can publish it to multiple destinations.
I have created a NuGet package which can be used for this exact purpose. It's called package-web. When you add it to your web project it will update the packaging process. When you create a package a few additional files will be included in the package, including all the web.config transform files. A .ps1 file will be created next to the package as well. You can use this script to publish the package. It will prompt you for which transform to run and for all the Web Deploy parameters. You can also save the responses to a file and then just pass them to the .ps1 file so that you can perform non-interactive publishes. I created a 5 minute video on it at http://nuget.org/packages/PackageWeb
package web: http://sedodream.com/2012/03/14/PackageWebUpdatedAndVideoBelow.aspx. FYI this is not yet working with VS 2012 but I'm working on the fix and should have it updated by the time VS 2012 is released.
If you don't find that useful you can see how I implemented the solution at https://github.com/sayedihashimi/package-web and you should see examples of everything that you need to do to roll your own.
FYI if you need to transform any files besides web.config on package create then you should take a look at my VS extension SlowCheetah. Here is a blog about how to integrate it into a build server.
Do you have some predefined set of targets which all build.xml files you create contain?
For example, a lot of ant manuals suggest the following list of targets:
init
clean
compile
build
jar
test
javadoc
dist
deploy
webapp
What is the most large build file you met in your life? How many targets did it have and what are they? How often do you need more than predefined set of targets?
The goal is to develop some conventions to have standard buildfile template for any project having the notion of the maven-like approach in mind (when a lot of work happens under the cover, convention over configuration). Also it would be great if you know the place where one can find collection of different buildfiles to choose or to get inspired from.
I also use these targets in all ant files
init
clean
compile
build
test
javadoc
The build targets always creates the artefact, no matter whether it is a jar or war or whateveer.
You should also include structural things in your conventions like a shared repository for all libraries (versioned by some VCS).
Another thing would be to define properties for your jar versions i.g.:
lib.commons-collections=commons-collections-2.1.jar
lib.commons-io=commons-io-1.4.jar
which are referenced in all ant files, common.jar is a place where artifacts are placed in case other projects depend on them.
<path id="local-cp">
<pathelement path="${dir.common.jar}/${lib.shared}" />
<pathelement path="${dir.lib}/${lib.commons-logging}" />
<pathelement path="${dir.lib}/${lib.commons-io}" />
...
For deployment I use another set of ant files deploy_component-name.xml
After years with ant I would recommend to keep the number of targets limited, sometimes you may have a few more steps for code generation etc.
To see how others handle bigger projects you could download the source distribution of an application server to examine how they do this job.
int
build
jar
deploy
package
clean
test
I'm in the process of developing several custom build scripts for TFS and I'd like to know if there are any best practices for developing, testing and deploying TFS build scripts.
Do you setup development and QC environments that are seperate from the production build server? Are there other ways to isolate the process of developing the scripts from the rest of the build process so that builds scripts under development don't interfere with "production" builds?
Team Build likes to create work items, update work items and add labels as part of the build process which I'd rather not have happen for a "test" build.
jMM
Check out my answer here: Modular TeamBuilds
You can keep core functionality factored out into a common MSBuild file that's included across all builds. Furthermore, all of these files are part of your broader branch structure, so they participate directly in your preexisting SDLC without any extra work. Thus:
If you're making risky changes to your build scripts, make them in a "dev" or "private" branch, just as you would with any other risky changes.
If you want a build definition that's just for quick validation, set properties like SkipLabel, SkipWorkItemCreation, etc to False in the *.targets file imported by that build definition.
To expand on #2 a bit, let's take your example of "production" vs "test" builds. You only want to turn on features like labeling in production builds. So you would remove the SkipLabel property from TFSBuild.proj (and also TFSBuild.Common.targets if it's defined there) and instead set it in TFSBuild.Production.targets and TFSBuild.Test.targets -- using two different values, of course.
As mentioned in the earlier question, TFSBuild.proj is the master msbuild file that controls how the rest of the build will operate. Here's what mine looks like:
<?xml version="1.0" encoding="utf-8"?>
<!-- DO NOT EDIT the project element - the ToolsVersion specified here does not prevent the solutions
and projects in the SolutionToBuild item group from targeting other versions of the .NET framework.
-->
<Project DefaultTargets="DesktopBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<!-- Import configuration for all MyCompany team builds -->
<Import Project="MyCompany.TeamBuild.Common.targets"/>
<!-- Import build-specific configurations -->
<Import Condition="'$(BuildDefinition)'=='Dev - quick'" Project="MyCompany.TeamBuild.Quick.targets" />
<Import Condition="'$(BuildDefinition)'=='Main - full'" Project="MyCompany.TeamBuild.Full.targets" />
<Import Condition="'$(BuildDefinition)'=='Main - quick'" Project="MyCompany.TeamBuild.Quick.targets" />
<Import Condition="'$(BuildDefinition)'=='Release - full'" Project="MyCompany.TeamBuild.Full.targets" />
<!-- This would be much cleaner as we add more branches, but msbuild doesn't support it :(
Imports are evaluated declaratively at parse-time, before any tasks execute
<Target Name="BeforeEndToEndIteration">
<RegexReplace Input="$(BuildDefinition)" Expression=".*\s-\s" Replacement="">
<Output TaskParameter="Output" PropertyName="BuildType" />
</RegexReplace>
</Target>
<Import Condition="$(BuildType)==full" Project="MyCompany.TeamBuild.Full.targets" />
<Import Condition="$(BuildType)==quick" Project="MyCompany.TeamBuild.Quick.targets" />
-->
</Project>
By doing something similar, you can ensure that all builds from the Dev branch are "quick" builds (which for you means no labeling, etc), all builds from the Release branch are "full" builds, and builds from the Main branch can be either depending on which build definition the user launches from Visual Studio / TSWA. Myself, I have "quick" builds set up with Continuous Integration and "full" builds running nightly.