Office Addin - reading web.config appsettings for debug and release - excel

I am developing an Office Addin for excel using Visual Studio 2019. I have different settings like API urls, default user etc for debug and release. I want to save these settings in web.debug.config and web.release.config and let visual studio pick settings from the relevant file based on whether I am running project in debug or release mode.
Or if it is not possible to do read web.config file in JS, then is there a way to know if application is running in debug or release mode, so that I set these values accordingly.

You can use a standard web.config file. This is a standard file for configuring a web application (which is actually what an Office add-in is) that is hosted on the IIS/ASP stack.
In the pre-build or post-build actions you may copy an appropriate content/file to the output folder and use different content or configuration that way.

Related

Using Visual Studio 2013 for ASP.NET web site project

I am new to the Visual Studio 2013 IDE / Environment...
I have inherited an older (ASP.NET) web site that is currently being maintained using Microsoft Expression Web 4 (which is no longer supported by Microsoft). The test and production web sites are hosted remotely using IIS 7.5
I have two questions with regard to migrating from Expression Web 4 to Visual Studio 2013:
Is there any way to simply copy (FTP/download) the web site from the production server into Visual Studio 2013? i.e.: create a new empty web site in VS 2013 and then copy everything from the production web site. Will this retain “sub-web” folders, etc.? (I doubt it).
When using Expression Web 4 to publish pages to IIS – some of the files in Expression Web are marked as “Exclude from Publishing” (because some files like web.config differ depending if publishing to the test or production server). I have not found anything in VS 2013 for an ASP.NET web site project that allows me to set individual files so they are excluded from being copied to a remote web site. Does such functionality even exist?
Any insights would be appreciated.
Thanks in advance.
For #1 if you have Web Site project open in VS (not to be confused with Web Application project), you can right-click on it and choose Copy Web Site. This will bring up an window where you can connect to a remote site (e.g. with FTP) and sync files back and forth.
(Note: this feature is ancient and nobody knows about it anymore)
For #2, it depends. In the case of web.config, you can create a publish profile (right-click the project and choose Publish) that will let you use web.config transforms to modify the web.config file for each publish destination. Once your publish profile exists, you can right-click on it in Solution Explorer and choose Add Config Transform, which will only apply when you publish to that destination.
For other files you wish to exclude, you can modify the .pubxml file for your publish profile as described here using <ExcludeFilesFromDeployment> and <ExcludeFoldersFromDeployment>. (The blog post talks of editing the project file, but that's no longer necessary since VS2012; use the .pubxml files instead.)

VS2012 Build page has not effect on debug or release settings?

I am trying to build a project for release in VS2012.
I got to Properties->Build and change the configuration to Release, set my platform (x86) and rebuild expecting the code to be optimized and put in the x86/Release folder.
The code is placed in the same Debug folder and I can still do real-time debugging which means in is not release.
If I go to the Configuration Manager I can change the Active solution configuration to Debug or Release and that works, but once again regardless of how the build page is configured.
I want to the Build page to control how the project is build not the configuration manager as it did in VS 2008 and 2010.
All online resources talk about using the build tab for control and the configuration manager for adding new Configurations, but nothing about requiring the configuration manager.
The Build page doesn't control which configuration you're building, it only controls what the settings are for each configuration.
To change the active Configuration, you need to use the Configuration Manager or the Solution Configurations dropdown in the toolbar.

Visual Studio 2012 Website Publish Not Copying .pdb files

I have used VS 2010 and VS2008. When I used them with my WCF Service projects, my .PDB files were always copied when I did a Publish Web Site. Now, with VS2012, no PDB files are getting copied when I do a Publish Web Site. The PDB files ARE getting created for both Debug and Release but nothing happens when I do a Publish Web Site (for either Debug or Release).
I have searched this forum (and the Internet). My solution is as follows:
1) WCF Service Library project.
2) WCF Service Web Site
When I first did a publish, I had to create a profile and I did this.
When I right-click on the WCF Service Library project and select properties, I only get tabs for Application, Build, Build Events, Debug, Resources, Services, Settings, Reference Paths, Signing, WCF Options, Code Analysis. I do NOT get tabs for Package/Publish Web and other items that I used to get. I tried to right click on my WCF Service Web Site project and there is nothing in the Property Pages to indicate this.
I have even tried to add items to my .pubxml file and that does not work.
I wouldn't think I'd need to update my Debugging options to specify Symbols location. I would think that my Publish should just "do it" like it did in 2008 and 2010. Any advice?
Thanks In Advance.
In VS2012 Website publishing, symbols are always excluded by default. Why? It comes down to a design issue where website projects don't actually have a build configuration. If you look at the configuration manager in VS when your solution is in Release mode, the website project will always be in Debug mode; there are no other options. This is because website projects are not MSBuild based, and hence do not respect MSBuild configurations.
Instead, you can edit your .pubxml to tell it to include the symbols. Try adding this:
<PropertyGroup>
<ExcludeGeneratedDebugSymbol>False</ExcludeGeneratedDebugSymbol>
</PropertyGroup>
For me this worked (in the publishing profile):
<PropertyGroup>
...
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
Or using the publishing wizard:

TFS/MSBuild build/publish web deploy does not transform the web.config files

I'm trying to deploy a two-websites project in a Visual Studio 2012 solution via TFS as part of a build. We're at the point where we have two different web servers, WIP (work in progress) and DEV.
We want to deploy different connection strings to either server so they can connect to different databases. We've tested our solution on a development machine with Visual Studio and for all configurations, when any web project is published, the web.config connection string is transformed as expected when we check the web server.
The build is working fine on the WIP server which uses the default Debug solution configuration. The configuration in the TFS Build is Any CPU|Debug.
For the next configuration (DEV), we are sure that the web projects both publish via Visual Studio 2012 to the web servers and that the web.config files transform.
However, when we run the DEV build using MSBuild arguments, we notice that no transformation happens. We've sent the configuration in the Items to Build section of the build to: Any CPU|Dev.
/p:VisualStudioVersion=10.0 /p:DeployOnBuild=True;PublishProfile=app.ui.dev.pubxml /p:DeployTarget=MsDeployPublish /p:MsDeployServiceUrl=https://server-dev-hrtech:8172/MSDeploy.axd /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=WMSVC /p:AllowUntrustedCertificate=True /p:Username=username /p:Password=password /p:_WPPCopyWebApplication=True /p:PipelineDependsOnBuild=False
When we look at the build log and output directories - we can see compiled assemblies in the obj/Debug directory and not the obj/Dev directory as we'd expected. In the logs, we can clearly see /p:Configuration="Dev" as we'd expect.
The bottom line is the published web.config that ends up on the web server is the default web.config file from the Debug configuration (that is, untransformed). It is as if MSBuild is unable to see the configuration parameter passed in the arguments for the solution.
I've now tried running msbuild from the command line on my development machine to try and understand why this would happen.
By stripping back the MSBuild parameters that are sent via the TFS build, I can see that this doesn't transform the web config:
msbuild "app-no database.sln" /t:app_ui:Rebuild /P:TransformConfigFiles=true /p:Configuration=Dev /p:Platform="Any CPU" /p:MSDeployServiceUrl=https://app-dev-hrtech:8172/MSDeploy.axd /p:Username=username /p:Password=password /p:DeployOnBuild=True /p:PublishProfile=app.ui.dev.pubxml /p:VisualStudioVersion=11.0 > build.log
I can modify this and use MSBuild to build the project file directly. I've discovered that the command below does transform the web.config file for the published application:
msbuild app.ui\app.ui.csproj /p:Configuration=Dev /p:MSDeployServiceUrl=https://app-dev-hrtech:8172/MSDeploy.axd /p:Username=username /p:Password=password /p:DeployOnBuild=True /p:PublishProfile=app.ui.dev.pubxml /p:VisualStudioVersion=11.0 /p:AllowUntrustedCertificate=True > build.log
The problem is this would be difficult to run as part of a TFS build where they are multiple projects which some for websites and others for Windows servers, etc.
How can I use the first command, but amend it so that it properly transforms the web project?
As you can see I've created some publish profiles, so potentially they can be used in the MSBuild arguments as well in the TFS Build.
PS: we're using Visual Studio 2012, TFS 2010, Windows 2008R2 for servers and Windows 7 for development machines.
I've encountered this problem, regarding how to publish a web site through Publish Profile file, this article is the best one I ever saw.
For you case, it seems that you need to make the profile name same as the configuration name, e.g. use Dev.pubxml and Web.Dev.config.
/p:DeployOnBuild=True;PublishProfile=app.ui.dev.pubxml
I dont think that .pubxml should be at the end of the profile.
Should be like this
/p:DeployOnBuild=True;PublishProfile=app.ui.dev
It looks like TFS 2010 Build doesn't call the Transform MSBuild task by default. You need to edit either your TFS build defintion to add a new activity which calls it or edit your project file to do this.
Stack Overflow question TFS Build not transforming web.config as expected should help you with adding the new acitivty and blog post Integrating Web Config Transformations with TFS Build for making changes to the project file.
I just had this problem. Checked the MSBuild logs, checked making a local ZIP package, checked Web Deploy push to remote IIS and it was always using the default config file!
Turned out that the lump of XML I was looking at to check for my QA settings was lacking the xdt:Transform="Replace" attribute!
Hope this helps someone.

Do you get an easy to use IIS Installer?

I have just finished the development of a web service application in visual studio.
Is there an easy way to wrap it in an installer, so that I can just ship it off to technical support, and they can have a wizard based installer that will fully setup an IIS site for them, either in 6 or 7?
You can use Visual Studio's built in setup project. I've only tried this once on a test project, but it created all the necessary stuff in IIS 6 just fine.
I would suggest you export the IIS METABASE for your local instance of the service and then this can be imported into a new server to create the correct IIS configuration. Have a look at Copying IIS Configurations using iiscnfg.vbs The METABASE is just an XML file and you will easily see the specific values that allows you to edit them should the deployment be different in anyway.

Resources