Visual Studio web deploy - simple way to include build info? - visual-studio

I have an ASP.NET site that I am deploying to Azure Websites. I have a production and staging environment there and it is easy to get lost which is which. During the web deploy ("Publish") from Visual Studio, is there some simple way to deploy some kind of build info that I could display either via the site itself or through the Azure Portal?

You can add a version number to your assembly by adding this line to AssemblyInfo.cs file
[assembly: AssemblyVersion("1.0.*")]
more details here and here
you can then expose it in your site however you want, maybe a hidden tag, some sort of debug info page, or write it to a file on Application_Start that you can look at later
for example in global.asax you can have
protected void Application_Start()
{
using (var writer = new StreamWriter("version.txt")
{
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
writer.WriteLine(version);
}
}

Generating a text file with current date as a post-build step was the easiest solution I found.

Related

Is there a way to create a TFS/VSTS label whenever a project is published?

IS there a simple method or extension to create TFS/VSTS labels whenever a web application project is successfully published?
I've looked into creating a task step to execute the TF command after publishing, but it seems a clumsy way to do it when VS2019 already has methods to add labels.
I am afraid there is not a simple method or extension that can do this in VS2019.
But you can try publishing your web application in the pipeline, which you can configure to label your sources automatically after publishing the application.
See below screenshot:
On the Edit page of the pipeline-->go to Get sources section-->select On success/Always to Label sources-->Specify a Label format

How can I debug projects that extend Umbraco 7?

I'm writing some code that integrates with Umbraco v7, at the moment specifically with the Umbraco Forms extension but in the near future with the CMS itself. I have nuget'd the Umbraco assemblies into my VS project and have a working instance with all the relevant packages and customisations in place by following the steps described in this article.
I have a second project, let's call it Project2 in the solution which will generate the DLL I'll be dropping into Umbraco's bin folder in production to allow the CMS to auto-hook-up to the additional functionality.
So far all well and good, but I have hit a problem - debugging. If I drop the Project2 dll into Umbraco I can use the Umbraco logger to generate output messages but this is woefully inadequate for debugging more complex code, not to say frustratingly time-consuming. But I can't see how I can connect the Visual Studio debugger to Project2 at runtime. Can anyone suggest a technique I could utilise?
I've sort of figured it out with the aid of this post which at least allows me to hook into things like events like Published with my own code which can be debugged in VS.
The technique is this:
Edit the Global.ascx file in the main Umbraco project so that it uses a custom Global.cs file in Project2. Of course you have to add a reference to Project2 in the main Umbraco project in order to do this. This is your hook.
<%# Application Inherits="Project2.Global" Language="C#" %>
And in this file (which is in Project2) you attach custom handlers for the various Umbraco events. And from this point in all the hooks are in place to allow you to debug your custom code. Slap some breakpoints in there and kiss the LogHelper goodbye ;-)
public class Global : UmbracoApplication
{
public override void Init()
{
var application = this as HttpApplication;
//Hook up your event handlers as required.
application.PreRequestHandlerExecute += PreRequestHandlerExecute;
ContentService.Published += ContentService_Published;
base.Init();
}
//Custom logic which you can step-through in VS.
private void ContentService_Published(IPublishingStrategy sender,
PublishEventArgs<Umbraco.Core.Models.IContent> e)
{
LogHelper.Info(this.GetType(), "Caught Publish event " + e.PublishedEntities.FirstOrDefault().Name); //very droll.
}
...
}
Phew! Hope this helps someone.

Customise RTLCSS config for VS Web Essentials 2013

Visual Studio Web Essentials has the ability to auto-generate a Right-To-Left variant for CSS files.
This will automatically change CSS properties such as padding-left to padding-right.
However it also does other things such as changing file names from "right.png" to "left.png".
Web Essentials uses RTLCSS to do this which I know can be configured to turn some of these features off.
There is no obvious option in Visual Studio to be able to config RTLCSS through Web Essentials.
I know that Web Essentials is consuming RTLCSS via NodeJS using the following file:
C:\Users{username}\AppData\Local\Microsoft\VisualStudio\12.0\Extensions{webessentials}\Resources\nodejs\tools\server\services\srv-rtlcss.js
I could update the following line in this file to add custom options, however this would be specific to my machine and not the MVC solution I'm using:
var config = configLoader.load(null, path.dirname(sourceFileName), { options: { minify: false } });
Is there a way I can configure RTLCSS for Web Essentials specifically for my MVC Solution?
For example I know Web Essentials allows Solution specific settings via a WebEssentials-Settings.json file. Can I customise this file to use a version of the srv-rtlcss.js file which I could include in my MVC solution?
Configuration can be set using one of the following methods:
Put your config into your projects package.json file under the rtlcssConfig property.
Use a special file .rtlcssrc or .rtlcssrc.json
To edit the global RTLCSS settings, open web essentials menu then select "Edit global RTLCSS settings (.rtlcssrc)"
This will create the default configuration for you and place it in C:\Users\{username}, To make these settings local, create a copy of .rtlcssrc and place it in your project.

Sharepoint 2010 WSP deploy wont update site

Im not very used to the whole Sharepoint-thing, but usually I just simply deploy my visual studio stuffs as a wsp-package and then deploys it using PS (if I dont remember incorrect)..
Now this time I wanted to update the masterpage of my site, and add a few javascript files and update an existing javascript file.. and this time for some reason the deploy did update the allready existing javascript-file, but it didnt add the new javascriptfiles..and it didnt update the masterpage for some reason.. and I have dubble-checked that the package Im depolying contains the new files and the updated masterpage, I also checked the Elements.xml-file for the javascript files and they are there.. Any ideas?
Check if you files are customized from definition (in SharePoint Designer they will have an (i) symbol. If so - revert them to definition and try to deactivate the feature again.

MVC3 Global.asax.cs events not firing in local IIS

I have an MVC3 application, trying to register/run this in IIS (6.1 and 7.5 Express) so I can run it as a local server and debug it via VS2010. For some reason the events in the Global.asax.cs file are not firing. Namely Application_Start so consequently, the RegisterRoutes is also not being called.
I use Re-sharper and it's telling me Application_Start() is never used which is strange as when I use the ASP.NET local web server (Project Properties, Use Visual Studio Development Server) this is called and executed as expected.
The problem seems to lie with running the app via IIS??
The file is a .cs file so I tried creating a Global.asax and inheriting the Global.asax.cs as per code behind. I also looked in IIS Manager > Handler Mappings > ExtensionlessUrlHandler-ISAPI-4.0_64bit thinking along the lines of the MVC routing - still, I cannot find a solution here either.
I've had a dig through posts on here and asked Google but failed to come up with a solution. Any other ideas?

Resources