Reputation: 4854
I am trying to add a BuildStep to the AfterBuild target in MSBuild and I am using the following
<Target Name="AfterCompile">
<ItemGroup>
<TestAssemblies Include="$(OutDir)\DataStoreUnitTests.dll" />
</ItemGroup>
<BuildStep
Name="Run unit Tests"
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Message="Running unit tests">
<Output TaskParameter="Id" PropertyName="StepId" />
</BuildStep>
<Gallio
Assemblies="@(TestAssemblies)"
ReportTypes="html"
ReportFileNameFormat="buildreport{0}{1}"
ReportOutputDirectory="." />
<BuildStep
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Id="$(StepId)"
Message="Yay! All tests succeded!"
Status="Succeeded" />
<OnError ExecuteTargets="MarkBuildStepAsFailed" />
</Target>
<Target Name="MarkBuildStepAsFailed">
<BuildStep
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Id="$(StepId)"
Message="Tests have failed. See test report in drop folder for details."
Status="Failed" />
</Target>
And when I run it in MSBuild I get the following error:
error MSB4044: The "BuildStep" task was not given a value for the required parameter "BuildUri".
And I cannot see why, does anyone know?
Upvotes: 1
Views: 3986
Reputation: 11770
Are you running this target as part of a Team Build (on the build server) or as a Desktop build (i.e. locally)?
The BuildUri property is normally populated passed in to the build by the build agent when it is triggering a new team build. In your script the Uri is used to tell TFS what build detail to attach the build step to. If you are running a desktop build then this will be empty unless you pass the property in on the command line.
Upvotes: 4
Reputation: 43855
My thoughts are that $(BuildUri)
is evaluating to nothing. Try doing a print statement to debug and target the line number that VS/MSBuild is giving as an error.
<Message Text="$(BuildUri)" />
MSBuild can be run from the command line (I find MSBuild to be easier to work with that way) with the following command:
C:\WINDOWS\Microsoft.NET\Framework\%FrameWork_Version%\MSBuild /verbosity:n
%Solution or Project file%
To set $(BuildUri)
:
<Target Name="AfterCompile">
<PropertyGroup>
<BuildUri>Build_Uri_Value</BuildUri >
</PropertyGroup>
<ItemGroup>
...
Information on BuildUri can be found here:
What is the BuildUri and where do i get it from when i'm just trying to get some source?
Upvotes: 4