Multiple Publishing web.configs in Visual Studio 2010 - c#

In my settings, I have two String settings and one connection string. These obviously show and are changeable in the web.config.
On top of that, not in the settings, but in the web.config, I have my entity framework connection String.
I also have 4 different publishing profiles (Addresses to publish my website to)
However: They all run off the same config file. So I have to change it manually before each publish. And if i forget/get it wrong, the entire site siezes to work.
Is there any way, to link publish specific web.config files. So that each publish profile generates the correct version, with its correct values/connection strings.
Ive come accross transforms, and pubxml, but nothing seems to make sense or work, or even be compatible with VS 2010.
If anyone can link or explain the path i should be taking to achieve this, i would be gratefully happy. I have spent days trying.

You can create a new configuration in the Configuration Manager and then create the corresponding config for that profile.
When deploying, if you change the configuration to the correct one, it will then pick up the appropriate config.
How to: Transform Web.config When Deploying a Web Application Project

I would take a second look at web config transformations - it was built for exactly this and is most definitely supported in VS 2010. Alternatively I have worked with a deployment setup where there was a custom utility that did exactly what web config transforms does by running as a build task. Using the two I would still recommend web config transformations due to it being well documented.

The .pubxml and profile-oriented transforms are available in VS2010 through the Azure SDK Bundle. Here's how to do it:
Have VS2010 installed. I'm using VS2010 Ultimate RTM (had to set up a new machine).
Install the Azure SDK. I'm doing this through the Web Platform Installer; it looks like the last Azure SDK for VS2010 was 2.1. This includes SP1 (if you don't have it already), a further hotfix, and the out-of-band tooling update to support .pubxml, as well as a bunch of other things. If you just want the VS components, I think you can find them at http://azure.microsoft.com/en-us/downloads/archive-net-downloads/ under July 2013 (Version 2.1)
At this point, you can create publish profiles as many of the newer blog posts show:
And add transforms for them:
And preview the transforming effects of each profile's transform (which does take into account the Debug/Release ones as well):

Related

AppSettings for different environments in Visual Studio 2022 and .Net 6

Visual Studio 2022 using .Net 6.
Im going through a few tutorials and one thing ive come across has me a little stomped regarding the usage of appSettings.json which has replaced web.config.
In prior versions i could create a new configuration within the Configuration Manager option and set new environments i.e. Home, Office, Staging and left the Release one as is.
Following this i could use the dropdown to switch between environments and i used to expand the web.config to view these files/settings for the appropriate environment.
In the current version i see appSettings.json and carried out the same steps but no new configs appear (even if i show all hidden files) when i expand appSettings.json.
After researching around im a little confused as some parts are targeting .Net Core 3.0 or similar, other threads continue to use the web.config so not sure if something has changed between versions for .Net 6 and appSettings.json but how do i configure to use different environments?

MVC core MSI builder, how to create installer?

I've written an MVC core app. The next step is to wrap it in an MSI and distribute it to clients. The problem is this: I can't seem to find any built in way capture all the content files and dll's automatically and wrap them in an MSI. I've tried so far windows installer and wix (heat, to be precise) and both of them doesn't seem to have a built in way to work with .net core. Did Microsoft just decided it's not important enough or am I missing something important? I could try to put all the output and all the dependencies, file by file, but that would be hell to maintain, with the new Nuget approach there are many many dll's required for a project, together with all the content it becomes enormous. Any help would be appreciated
I'm still adjusting to this "modern" world and part of me wonders why you'd want to package a .NET core app as an MSI. I'd think you'd be running it in a docker container or windows server app (appx) in the "cloud" or on nano server which doesn't even support MSI. For actual windows servers I'd assume regular old .NET. (Which I still fondly love.)
That said, I have an open source program called IsWiX (CodePlex) and have a very simple pattern for creating ASP.NET website installers (see video at: https://www.youtube.com/watch?v=pgDf1kv8a-4) and I'd be willing to work with you to come up with a similiar story for asp.net-core mvc apps.
From what I read, .net core apps also have msbuild publish profile support. That is what I use to create the model from which I author my installers. From there I just drag drop my files into IsWiX and let it author all the XML for me.
FWIW website installers have always had a lot of files. Even before nuget and npm a website developer might add a few thousand files to their project just by adding say Infragistics. I once worked on an installer with over 300,000 files. Yikes! I always wished we had a way of just creating an uncompresssed archive of this stuff and IIS could see if as a directory but to my knowledge that never happened.
The MSI world is a declarative world where we need to explicitly list each of those files. Web developers live in a world where they just say "publish" and don't care about those details. That is the gap that I try to bridge with IsWiX.

How to deploy a compiled application without Visual Studio?

When I open a sample Blinky application in Visual Studio, compile and run it, it gets automatically deployed to the target configured WindowsIoT device. After that, on Windows 10 machine where I compile it, the application binaries are located in the bin sub-folder of the project folder as one would expect.
I would like to automate the deployment, so that I could run deployment code
without Visual Studio, specify target device and the binaries location and it would deploy it. I cannot find any API that allows
to deploy apps to Windows IoT, how do I do that?
This shiny Windows IoT stuff is a new area, and there is not a lot of info available apart from the samples and the getting started page. Any pointers are appreciated.
Update: As noted in comments, once one start thinking of mass production, they will probably need to conciser ICD. This, is not, however the problem I'm trying to solve currently. I would like to figure out how I can provide Over-the-Air updates to my UWP application running on Raspberry Pi and Windows IoT. I also would you like to know how I can automate build / deployment in general, but that may be automatically solved if I have a proper OTA solution.
There is a set of instructions on how to do it, which can be found in the same github repo you are linking in your question, but in a different folder. Note, that you need an appx for these instructions to work, and it's not created by the solution build by default.
This page provide (non IoT specific) instructions on using VS to build the appx. And this blog post talks about the command line tool that can be used for making appx.
Note, that the last two links are also talking about publishing an application to app store, so you'll need to make some mental adjustments around that.

Is the option (rightclick on proj) publishWeb and webdeploy extension the same?

I'm confused here, because I've never downloaded WebDeploy (msdeploy) but it's been some time since I use on my vs2010 (and 2012 too) the rightclick on webapp.csproj -> publish (which generates a .pubxml and makes the deploy happen).
Are those the same thing? and if not and I want to separate the deploy as the implementer's work, which is the best to do it?
I was thinking on passing to the msbuild a template with a somewhat embebed pubxml for it to do the magic. But IDK if it's possible or the best path
The publish option allows you to publish the website to and FTP, Web Deploy, FSPE etc. Web deploy is a way of deploying the package. You must install the WebDeploy on the IIS server which allows you to use it.
For more information about WebDeploy: http://weblogs.asp.net/scottgu/archive/2010/09/13/automating-deployment-with-microsoft-web-deploy.aspx

Installing patch for Asp.net web application setup

I am using visual studio web project to install my web application and do some customization like modifying connection string in web.config file during install time.
Now, My requirement is to create a patch for the web application so that next time the web installer only the changed files.
Is there is any one to do it using visualk studio 2010 ide or any other way.We can't use third party products like Installshield,wix,innosetup etc.
Please suggest.
Visual Studio doesn't support patches for setup projects. It supports only major upgrades.
If you really don't want to use other setup authoring tools, you can try creating the patch manually. You can read more about this here:
http://msdn.microsoft.com/en-us/library/aa370578(VS.85).aspx
But it won't be easy.
If it is just Web project, I would recommend re-deploy instead of patching. Meaning you just deploy new version of site, above the previous one.
Except some really comprehensive case that strategy works all the time. I use simple xcopy deploy for all my projects.
You can write a mini C# app to do it. You can have the list of assembly files in a configuration. On loading of the app, it checks the timestamp difference between server and client files. On finding the change, the mini app pushes the changes file.
Hope, it will resolve your issue
There may be better suited solutins to deply websites than using an installer. For one, there's Web Deploy.
It's main purpose is deploying web applications to IIS and it allows you to modify key configuration values through a simple UI.
Web Deploy works with deployment packages; a big zip containing your application and some meta data to help install it. On deployment it will diff the deployed site with the data in the deployment package to update existing files, add new ones and remove obsolete files.
You can build deployment packages directly from Visual Studio and/or from MSBuild, using your favorite build server.
Web Deploy works really well when you need to deploy often or when you have to delegate deployment to IT staff.
Customizing Web Deployment package is a bit tedious though, you may find a blog post I wrote about this useful.
For simpler situations, I recommend good version control practices and xcopy deployment.
If you tag what you deploy to your server, you can zip up the changed files since last deployment and copy those to your server.

Categories