Sunday, 30 April 2017

TFS 2015 build configurations and config transforms

How to get the same code deployed to different environments but deploy debug builds to dev and release builds to prod (and additional builds to other environments), also taking into account configuration transformations.


Using the Configuration Manager in Visual Studio setup the appropriate configurations e.g. add a Test configuration. Debug goes to dev, Test goes to test, Release goes to production. Test and Release should have the same build configuration (if you want test environment code same as prod env code) but will have different config transforms applied (e.g. the connection strings for dbs will be different).


In Visual Studio go to the Build tab on the project properties and configure each configuration e.g. make the test configuration the same as the release configuration


Add any additional web.config transform files that are needed.  For a web.config you can right click. For an app.config project add each file manually, then unload the project file and edit it.  Make each of the transforms dependent on the app.config file.



Update the transform configs to have environment specific values; the application of these are controlled by the transform attributes. Only include elements that need to be changed. Items in transform will be merged into the original config i.e. you don't have to repeat data in here that isn't changing


In TFS config transforms will not happen automatically. To get this to work we manually add a step into the project file. This won't effect local builds. In Visual Studio unload the project. Edit the project file and add the transform step - it differs for app.config and web.config so add appropriately.

Web.config

  <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
  <Target Name="ApplyTransform" Condition="Exists('Web.$(Configuration).config')">
    <TransformXml Source="web.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
  </Target>
  <Target Name="BeforeBuild">
    <Exec Command="attrib -r Web.config" />
    <CallTarget Targets="ApplyTransform" />
  </Target>


  <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
  <Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')">
    <!-- Generate transformed app config in the intermediate directory -->
    <TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
    <!-- Force build process to use the transformed configuration file from now on. -->
    <ItemGroup>
      <AppConfigWithTargetPath Remove="app.config" />
      <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
        <TargetPath>$(TargetFileName).config</TargetPath>
      </AppConfigWithTargetPath>
    </ItemGroup>
  </Target>



Create a build for the solution in TFS.  There is a variable on the build called BuildConfiguration - every time this build is run it will compile the code using that configuration. E.g. if it is set to debug then the debug code will be what is released (i.e. it will go to dev, test and prod :( ).
To make TFS build all configurations from the same code set update the BuildConfiguration to be debug,test,release (a comma delimited list)


On the Options tab select the 'Multi-configuration' option, and in Multipliers enter the value BuildConfiguration


On the Copy Files action make the target folder contain the value of the BuildConfiguration (each in their own dir)


On the Publish Build Artifacts action but the BuildConfiguration value into the artifact name


When the build is run it will do a build for all three configurations



Three properly named artifacts will be created


On the release each environment has a file copy action with the source (and target) being different for each environment. This will copy everything. This could be better.




Sources:
http://stackoverflow.com/questions/3004210/app-config-transformation-for-projects-which-are-not-web-projects-in-visual-stud
http://stackoverflow.com/questions/8082662/how-to-select-different-app-config-for-several-build-configurations
https://codepunk.io/team-foundation-server-build-and-release-with-web-config-transforms/


Sunday, 30 October 2016

Microsoft Ignite New Zealand 2016 session reviews


Session reviews. reviews? reviews.

Tuesday


M200 An Intro to the SharePoint Framework Development Model - Gavin Barron


  • Currently only cloud (e.g. a waste of time) but may be on-premises at some point
  • can use the SharePoint workbench to develop without having SP installed
  • The Office UI Framework can be used to style things like office (lol)
  • All this stuff is done in Typescript which goes to our friend Javascript
  • Not sure if this is totally released yet ...

M308 High Availablility With SQL Server 2016 + always on availability groups - Warwick Rudd

  • 2016 = x64 = yay
  • Availability groups are included in standard edition, but are limited to replicating current database mirroring i.e. standard has less options
  • Single DB causes entire group to fail over (good)
  • This guy is really knowledgeable & is a good speaker but most of this is beyond me. Recommend for DBA

M310 From Zero to Power BI superhero - Dandy Weyn

  • Data is imported into Power BI Desktop and refreshed at set times (or direct Query or live/exploration -> can only do over SQL Analysis Server data source)
  • When you change the data set e.g. rename a column, it makes a history of changes. When data is refreshed it plays those changes over the new data
  • Mostly this is kind of vague

Wednesday


M317 Power BI for Developers - An Introduction to the API, the new Custom Visual SDK and Power BI Embedded - John Gallant


  • This is for the cloud, but there is a desktop version of Power BI
  • Custom visuals use node.js; need to install Power BI visuals SDK & install a local cert. These are just js with a power BI wrapper.
  • Power BI (in cloud) looks back to local machine to load stuff in dev e.g. /localhost:8080/
  • Lots of steps on his blogs about how to build custom visuals!
  • Somehow this was really interesting. Good speaker.

M321 DevOps in the real world: a true story - James Carpinter


  • details on what worked for them with modern software lifecycle etc
  • encourage VSTS as source of truth
  • can send a 'request feedback' from VSTS
  • there is a browser plugin for peeps without VSTS so they can provide feedback etc
  • Use branches a lot! every dev has own branch. Branch per workitem?
  • No transforms, branch per env
  • A lot of Azure focus (pffftt) but still really interesting. 

M328 From zero to DevOps - Donovan Brown


  • he reckons in theory we can write code well now (e.g. agile) so devops is deploying (& automating that) that code well
  • "DevOps is the union of people, process, and products to enable continuous delivery of value to our end users"
  • good overview, good speaker, some good slides on what part of devops use what technologies
  • investigate SSDT for db version + deployment control!
  • monitoring via Application Insights
  • This dude is super keen on automation, demo automatically created devops pipeline

M331 Deep Dive into the Microsoft Graph API - Andrew Coates


  • Office 365 related - connecting to office services
  • Graph is a single API (a wrapper) to all office apps
  • What - access data / traversing data (links between apps) / insights - this is like 'big brother' connections for people and data
  • I think this is all accessed via graph.microsoft.io
  • can do things like access fields in an excel spreadsheet, update outlook appointments

M335 Cryptolockers, CEO Fraud, DDoS extortion + cyber nasties - Andy Prow + Kirk Jackson


  • Interesting + informative + good speakers. Probably more for system engineers.

M344 The Power of Roslyn: Improving your productivity with live code analyizers - Kassey Uhlenhuth

  • JS talk was cancelled so I went to this!
  • Roslyn was released in VS 2015, along with C#6. C#7 is almost out in vs next (or vs15)
  • Analysers identify errors and help provide fixes in code as you type. Bascially like rehsarper does. Can popup suggestions.
  • A lot of resharper stuff has already been rewritten in this - you have to install em though (via nuget or VSIX)
  • Can create errors, warnings or suggestions
  • Will be out-of-process in v.next = better performance
  • debugging will start a new instance of visual studio with your analyser as a VSIX installed
  • Entertaining + interesting + good presentation
  • Loads of code in this :)

Thursday


M350 Internet Explorer and Edge in the Enterprise - Alan Burchill + Chris Jackson


  • Average age of webapps = 12 years. 50% code in enterprise is VB6
  • Edge = better security. isolation of tabs and content on tabes e.g. flash.
  • IE11 is not moving forward so support for ECMA 6 not progressing, gotta go to edge at some point
  • less group policies in edge because so many in ie11 that it created confusion + lots of permutations of configuration which made testing really difficult
  • IE and edge will wait 70 seconds after startup before downloading the enterprise list???????????????????????
  • Very interesting talk + good presentation

M232 Being Your Authentic Self - Dr Harold Hillman


  • JS talk cancelled so went to this ...
  • Good talk, interesting etc, not technical at all

M360 Property based testing with XUnit + FsCheck - Ivan Towlson


  • Property based testing: multiple inputs, the asserts describe what the results should look like i.e. the constraints rather than comparing actual values
  • inputs are rnadomly generated - incase of failure further tests are generated in a way to 'shrink' aka simplify the input - e.g. smaller input values
  • apply domain logic - expected ranges, values that should never be seen, relationships between inputs and outputs
  • interesting talk + good presentation, would recommend

M361 .Net Core for .Net developers - Bruno Tagliapietra


  • Omisharp addes .net editing functionality to VS Code. Yoeman can be used for scaffolding. What????
  • Deployment : framework dependant deploy = .net installed on server/target. Self-contained deployment = framework goes with the sapp.
  • demo of compile on windows and running on linux
  • demo of asp.net core running in a docker container with remote degugguing
  • Quite confusing overall. 

M369 Building cross-platform mobile applications with Xamarin and the Mircrosoft Graph - Andrew Coates


  • Can get an SDK for Xamarin (and some other stuff?) to use the graph rest API
  • graph is on azure, can you get it on premises?????
  • using xamarin/visual studio MVVM is a good model to follow
  • bit boring, kind of entertaining, not sure how relevant

M374 Boom! Compelling Visualisations with SQL Server - Rob Hawthorne

  • appears to apply to SSRS 2016 - at least there is a heap of new stuff
  • reporting services vs power bi. SSRS for paginated reports (aka corporate or big grids of data), single page/image heavy reports use power bi. cannot drill down easily/effectivley in power bi
  • can now publish power bi internally
  • kind of interesting, lots of folk asking questions, bit weird, not much flow due to all the questions

Friday


M380 C# and Visual Basic Code-focused Development with Visual Studio "15" - Kasey Uhlenhuth


  • Interactive Window! VS2015 update 1 + 2. Load with project context will put all refs of current project in interactive window. Proj doesn't have to be running.
  • VS2012 = C#6 vs VS2015(vs.next) = C#7
  • native ctrl T now! bye bye resharper?
  • ctrl dot will open the lightbulb (fixes) menu. REMEMBER THIS ONE!
  • use the ctrl. when things selected or when in code block or method signature
  • vs15 will do spelling mistakes. hmmm
  • ctrl. will install nuget packages on unrecognised types
  • VS2015 was all about compacting code + making more readable (this is when roslyn came out). It had:
  • the string format vs $
  • expression bodied methods = mthods with single line can use the =>
  • null conditional opperator
  • VS next is all about working with data. It has:
  • can return tuples (multiple return types) from a method. You can name the members in a tuple.
  • pattern matching - checking types (e.g. if have base, checking inh). e.g. if(p is Student || p is Teacher) {      when student and teacher are types
  • local functions - put functions in functions - these can access vars in parent scope.
  • Performance enhancements are coming
  • The version of C# depends on the compiler, the tooling support is based on the IDE.

M384 Beyond T-SQL non-relations features in SQL Server 2016 - David Lyth


  • Mostly I don't know what these database nerds are talking about
  • Json - openjson can be used to put json into a table, can extract value from json. Forjson used to turn SQL to json
  • R <- bring r code to data and running on sql server. used by data scientists
  • linking to big data that is not is SQL, azure, hadoop. can then treat as SQL tables. e.g. do joins on it. Files might be flat, CSV etc.

M251 IOT, Machine Learning + Power BI deliver advanced analytics for Auckland Airport - Mahindra Morar, Peter Scott, Darryl Wolfarrdt


  • Kind of interesting / not really applicatble (to anything?)

Tuesday, 10 March 2015

1st week (well, 8 days) report of emergency department whiteboard

1229 admissions have passed through the whiteboard – that was made up of a bit over 950 different patients.  One patient came through ED 9 different times.

We have had 3460 updates via the whiteboard (i.e. people entering/changing data through the whiteboard) including 40 via Concerto

The most commonly used specialties are Medical (98), then Surgical (57) then Orthopedic (38).
The most commonly used labs/tests are OBS (500!), then BLD (416) then IV (409).


The dataload has run over 3000 times so far.
3 identified bugs L (not counting requests to be added to the WebPAS nurse or doctor list or issues related to the backups)
When was Kelvin the most super stressed: 10:23pm on go-live day when the backups were grinding everything to a halt
When was Kelvin the most super relieved: 10:34pm on go-live day when the backups completed and everything started working again

Code statistics:

Code first checked in on 09/12/2013 13:21

4303 lines of .net code written
Around 3000 lines of javascript code
66 automated unit tests

360 code check-ins in total, including this one:
  



And also this one


Thursday, 26 February 2015

how do I link these stupid variables to the stupid properties in the stupid package

Using variables and a config file to determine which server a connection in SSIS (08) should to connect to.

Create a connection:





Create a variable to hold the server name to connect to:








Link the variable to a property in the connection THIS IS THE BIT YOU CAN NEVER REMEMBER HOW TO DO AND THUS HOW DO I PUT THESE STUPID VARIABLES INTO THE STUPID PROPERTIES.  Click on the connection, in the properties window (i.e. don't double click it) find the 'Expressions' entry, when you expand that you can map variables to properties in the connection:





Then you can go and create a config file with all your variables in it:


Take a copy of the config file and populate it for a given environment.  Then when you make the job, link it to your updated config file: