Simulating "Publish to folder" Functionality in Visual Studio 2010
Visual Studio has a handy "publish" feature for web sites. One piece that's really handy is the ability to publish to a folder -- just right click the project, choose Publish, click a few buttons, and you're all set.
msbuild /t:Build;PipelinePreDeployCopyAllFilesToOneFolder /p:Configuration=Release;_PackageTempDir=C:\temp\somelocation MyProject.csproj
This Linux thing... it's going places.
A maze of twisty little passages, all alike
stinky build scripts
holy crap I love lambdas (ok, delegates :-)
I pity the poor Java coders, really I do. (Of course at night I am one, but that's another matter.)
Teardown logic in test code can be a pain point, as described by Gerard Meszaros in his book xUnit Test Patterns. Suppose you have code like this:teardown1(); teardown2(); teardown3();If teardown1() fails, then teardown2() and teardown3() are not executed.So you might write something like this...
try {
teardown1();
}
finally {
try {
teardown2();
}
finally {
teardown3();
}
}
Which doesn't scale at all when you have a lot of teardown code. Enter lambdas -- specifically, Action<T>. This guy gives you a quick syntax for defining a method that returns void. So now you can aggregate your teardowns in a list, then call each of them one at a time.
// Behold a beauteous delegated teardown.
List<Action> tearDowns = new List<Action>
{
() => teardown1(),
() => teardown2(),
() => teardown3()
};
foreach (var teardownAction in tearDowns)
{
try
{
teardownAction();
}
finally
{
}
}
Actually, since the methods being called are themselves all void in this example, you can just use them like so:
// Behold a beauteous delegated teardown.
List<Action> tearDowns = new List<Action>
{
teardown1,
teardown2,
teardown3
};
foreach (var teardownAction in tearDowns)
{
try
{
teardownAction();
}
finally
{
}
}
Now when we want to add a teardown, instead of hunting through a nasty indented set of existing ones we can just tack another lambda onto the end of the list. And with the time you save, you can write a blog post about it. :-)
Two things that make me happy.
2. You can define extension methods on interfaces in C#. And since classes can implement multiple interfaces, this makes it possible to pretend to have multiple inheritance (without any of that pesky state coming along for the ride).
Varisimilitude
Stupid gits
The Agile Home
- Have a first sprint meeting
- Determine how many hours we actually each have per week to accomplish stuff
- Create a prioritized backlog of things we need to do
- Do T-Shirt sizing on each item
- Choose the most important things to do in our sprint
- Place items on 3x5 cards and place on a Scrum board
- Every day have a daily stand-up to discuss what we did yesterday, what we're doing today and what's getting in our way of our tasks
- As we complete items, move them to "To Be Verified" on the scrum board, and write on the card how long it took
- Every week have a sprint meeting
- Move all verified items to done (if they can be verified)
- Quick retrospective: what went well? what didn't? how do we fix what didn't work? how were our estimates?
- Take the next hunk of items off the backlog and move them to the board
LINQ-to-SQL-Via-T4-Is-Wicked-Pissah
Seriously. I don't know how I ever used LINQ-to-SQL before I found the L2S T4 Generator. It actually makes the thing usable.
Today I had to turn off optimistic concurrency checks. I've been getting spurious errors as a result of some datetime fields that is well-documented on the Internet. Instead of trying to find and fix each one, I've decided that this application really doesn't need to protect users from each other. If two people happen to be updating the exact same thing, no worries. The last one wins. If I wanted to do this with the L2S designer, I'd have to click on each column, then go to the properties window and change the desired concurrency level. Instead, I can add the following to the T4 template:var options = new {DbmlFileName = Host.TemplateFile.Replace(".tt",".dbml"), // Which DBML file to operate on (same filename as template)
SerializeDataContractSP1 = false, // Emit SP1 DataContract serializer attributes
FilePerEntity = true, // Put each class into a separate file
StoredProcedureConcurrency = false, // Table updates via an SP require @@rowcount to be returned to enable concurrency
DisableOptimisticConcurrencyChecks = true, // Remove any UpdateCheck statements, so the last run statement wins.
};// ... //
if (options.DisableOptimisticConcurrencyChecks) {
#>, UpdateCheck=UpdateCheck.Never<#
}
else {
if (column.UpdateCheck != UpdateCheck.Always) {#>, UpdateCheck=UpdateCheck.<#=column.UpdateCheck.ToString()#><#}
}
And my generated code now has "UpdateCheck.Never" set on every single column, so my updates are all performed against the primary key ONLY. Ahhhhhhhhhhh.
The disadvantage to this technique is that it is quite a bit more opaque. The designer still says "Always" instead of "Never" as the T4 template is completely disconnected from it. I've left a text file in the same folder to explain my changes to the template in hopes of helping out the poor future maintainer.
