1

I have a solution with 2 Web application projects that I have configured with continuous integration and deployment to the IIS Test enviroment. It works perfectly and I'm very happy with that.

Now, I would like to display, in the deployed websites home page, some info that allows me to know what is the current build. Is there any way to retrieve this kind of information?

Thanks in advance

Agustin Meriles
  • 4,866
  • 3
  • 29
  • 44

2 Answers2

1

Yes, couple of ways to do this

Read assembly info

Usually as part of your CI build steps, you would add versioning numbers, company details, sign libraries etc. You will be able to read this info when a request comes from the library with updated metadata. Code snippet to try, make sure to find correct dll though, as on IIS it may not be the executing assembly.

Embed custom app config values

Similarly as part of the build process you may do xml-poke or xml-transform to insert some values into the web.config, for example into the <appsettings> section. MS build sample. You would likely to use ConfigurationManager.AppSettings from the web application.

Community
  • 1
  • 1
oleksii
  • 35,458
  • 16
  • 93
  • 163
1

There is a really fabulous XML file that can be generated when you build. Called the BuildInfo.config file. https://msdn.microsoft.com/en-us/library/dn449058(v=vs.120).aspx

/p:GenerateBuildInfoConfigFile=True

creates BuildInfo.config at the root of the web project

<?xml version="1.0" encoding="utf-8"?>
<DeploymentEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/VisualStudio/DeploymentEvent/2013/06">
  <ProjectName>Agriculture</ProjectName>
  <SourceControl type="TFS">
    <TfsSourceControl>
      <ProjectItemSpec>$/ServerPath/To/Your/Project.sln</ProjectItemSpec>
      <ProjectVersionSpec>C39469</ProjectVersionSpec>
    </TfsSourceControl>
  </SourceControl>
  <Build type="TeamBuild">
    <MSBuild>
      <BuildDefinition kind="informative, summary">CIA_TEST</BuildDefinition>
      <BuildLabel kind="label">YOUR_PROJECT_20170406.04</BuildLabel>
      <BuildId kind="id">a7e16be8-141d-4193-b200-b57b19f1564a,vstfs:///Build/Build/34814</BuildId>
      <BuildTimestamp kind="informative, summary">Thu, 06 Apr 2017 16:49:22 GMT</BuildTimestamp>
      <Configuration kind="informative">Release</Configuration>
      <Platform kind="informative">AnyCPU</Platform>
    </MSBuild>
  </Build>
</DeploymentEvent>
JJS
  • 6,431
  • 1
  • 54
  • 70