Today I’ve been fixing up the build system for Microsoft.Activities and Microsoft.Activities.UnitTesting. Over time I’ve been using a combination of strange tools and batch files to build things but it became such a mess I decided to take the time to finally build a good project file that I can use MSBuild on that will do everything
The first problem I ran into was that my unit tests use the [DeploymentItem] attribute to deploy files when testing with MSTest. The problem is that the test considers the $(SolutionDir) the root folder for the test. Previously I had just the Solutions for Microsoft.Activities and Microsoft.Activities.UnitTesting but now I made a single solution file in a different location with everything. This cause my tests to be broken because the deployment paths were wrong.
After much searching I finally decided the best thing to do was to use an environment variable. Since I call these projects “Labs" projects (for historical reasons) I decided to use a variable called “LABDIR”.
3: public void LoadAndInvokeShouldRun()
But then, what if I try to build on another machine where LABDIR is not set? I decided to modify the Test Project so that it will fail the build if the variable is not set. Ok – search engines take note of the following question so that the next guy searching for this can find it.
Just add this to the end of your Test project .csproj file
1: <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
2: <!--To modify your build process, add your task inside one of the targets below and uncomment it.
3: Other similar extension points exist, see Microsoft.Common.targets.-->
4: <Target Name="BeforeBuild">
5: <Error Text="The LABDIR property must be set on the command line or environment variable must be supplied."
6: Condition="'$(LABDIR)' == ''" />
8: <Target Name="AfterBuild">
Now if I try to build the test project without LABDIR set, I get this.
Error The LABDIR property must be set on the command line or environment variable must be supplied.
Can I ask a question not related to this post, Would you please give us an example on how to do Try catch inside statemachine workflow, so that my workflow would not being termiated and I can resume the step or transitions from where it is error out.
You can put a Try/Catch activity in the StateMachine in either the Trigger or Actions area.
Thank you very much, I will give it a try.