Create Text File on the Fly in Build Scripts
January 30, 2009
Yesterday, we made a final touch to our build script (by “we” I mean “I talked about it for five minutes, Christer did it”).
We needed to create a .bat
file that installs our database for a specific version and environment. The necessary information is only known at runtime in the build script.
I remembered there was an MSBuild community task for this purpose, and Christer found the task WriteLinesToFile. He then wrote the following target to create the .bat
file:
<ItemGroup> <CmdLine Include="@ECHO OFF"/> <CmdLine Include="ECHO About to install version $(BuildVersion) on environment $(DeployEnv)"/> <CmdLine Include="SET /p passw=Enter DB password for $(DeployEnv): "/> <CmdLine Include="CALL main.bat $(DeployEnv) . $(BuildVersion) %passw%"/> <CmdLine Include="PAUSE"/> </ItemGroup> <WriteLinesToFile File=
Read More
RefCardz - Great First Stop
January 23, 2009
Here is a nice link that holds a lot of interesting RefCards on various subjects (C#, Ruby, SOA, etc.).
I’ve found it useful several times already. Thanks to Patrik for the tip.
Read More
NMock2 RemotingException ByRef value type parameter cannot be null
January 22, 2009
OK this might be the most misleading error message I’ve seen. I cannot decide on how to describe it… What this means… or what this try to … Actually this happens when one of your mocked objects is mocking a method that returns something and your mocking doesn’t return anything. Eeeh - that was quite tricky.
Got it? Here is an example:
When I mock this method:
Public Class FacadeObject Function CreateSomeThing(ByVal aName As String) As Long End Function End Class
by using the following code to do the mock
Expect.Once.On(m_mockadFacadeObject).Method("CreateSomeThing")
an exception of RemotingException (ByRef value type parameter cannot...
Read More
Update AppSettings with XmlUpdate in Build Scripts
January 20, 2009
I know I will chase this one forever if I don’t put it up here…
We encountered a situation where we needed to tweak the AppSettings
section of a configuration before running tests in the build script.
Luckily, there is a solution available. With the XmlUpdate
task (from the MSBuild Community Tasks), you can accomplish this—if you know how to write the XPath query.
Here’s how to use it (I found this example here):
<XmlUpdate
Namespace="http://schemas.microsoft.com/.NetConfiguration/v2.0"
XmlFileName="$(SourceDir)\Core\ABSuite\ABClient\App.config"
Xpath="//configuration/appSettings/add[@key='Main.ConnectionString']/@value"
Value="$(DatabaseConnectionString)" />
Additionally, if you need to brush up on your XPath skills, check out this XPath tutorial for some great examples.
Read More
How to read other exe's config
January 15, 2009
When we’re doing integration tests we need to find some settings from
the exe (yes, we’re batching some stuff - I am sorry ;)) that we are
testing.
Instead of copying it into the test app.config I discovered a way to
read another exe’s configuration - OpenMappedExeConfiguration.
Very useful if a tad … ugly maybe.
Read More
ASP.NET MVC Storefront
January 14, 2009
I have been watching the first three in this
series
and not only are they a great introduction to ASP.NET
MVC, they also introduce
TDD in a very methodical and nice
way.
Follow along here -
http://www.asp.net/learn/mvc-videos/#MVCStorefrontStarterKit
Read More
Custom Tool Warning Cannot Import wsdl portType
January 12, 2009
I chased this bug for a while and got increasingly frustrated. Here’s what happened: I updated a WCF Service Reference and encountered the error (or actually a warning) in the Error List of Visual Studio. Additionally, the Reference.vb
file was completely empty.
After some experimentation and frustration (why do I always try things myself before searching for a solution?), I decided to look online. Fortunately, I found the answer quickly.
Travis Spencer’s blog provided a solution. Although the title and description of the post were quite different, the solution was what I needed.
In the “Configure Service Reference” dialog box, there is an option called “Reuse types in referenced assemblies.” This option is a bit vague in its purpose—essentially, it means the tool attempts to download the assemblies that the service is referencing.
To solve the issue, you don’t need to fully understand this setting. Simply uncheck...
Read More
WCF with Handcrafted WSDL Generated No FaultExceptions
January 7, 2009
This problem has haunted us for the good part of the autumn and winter.
Early on in our design process, we chose to create the WSDL for our services by hand. This decision was mainly due to the need to express details in XSD that WCF attributes don’t support, such as string length.
We were also using the ErrorHandlerAttribute from the excellent book “Programming WCF Services” by Juval Löwy.
What we observed was that, even though we had created the WSDL for handling faults and their details correctly, we didn’t get the fault details over to the client (i.e., the T
of FaultException<T>
). We checked the WSDL and the generated client proxy (and its WSDL) file over and over, line by line, but just couldn’t find the issue.
Finally, it dawned on us… It was Mr. Löwy’s fault. Seriously, it was the use...
Read More
2008 - another great year
December 31, 2008
To sum up 2008 is not very hard for me—it starts and ends with Abbe (Albert). He was almost a part of our lives at the start of 2008 since he took up considerable space in Elin’s belly. :)
In work, I don’t think I ever learned so much in one year (TFS, SOA, MSBuild, WCF, Oracle, just to mention a few things I have touched during the year). But it came at a cost—I lost my ability to leave work at work when I go home. I’ll try to improve that next year, which won’t be hard since I will be home with Abbe for about six months.
With the Vasa Band, it was also a great year with the recording and release of our CD Priority and a tour of the western parts of Sweden. On top of that, we did two great Christmas concerts at...
Read More
About this blog
December 30, 2008
Lately I have been asked the question why I have this blog, several times actually. I honestly thought that I wrote that in the first posting I did, but it was very short. Not even when I change into www.marcusoft.net I wrote something about it.
But the reason for the blog is, and has always been this simple: I write about things that interest me and when they catches my attention. For several years I did notes in different kind of notebooks at different customers. Always forgot them when I left. So now I have them in one place. I often link to the blog for solutions to problems I have and solve.
I then and then write about private stuff also, in the same manner - when it feels good.
I write in english to keep my english up to date.
So there you have -...
Read More