How to create virtual directory on Local IIS using MSBuild and properties of a project - visual-studio

I have VS2017 project with predefined usage of Local IIS in properties.
I have a Project Url as http://localhost/MyProject.Name there and want to see it on IIS the same way under Default Web Site (localhost:80, nothing special)
Default Web Site
|-----> other files
|-----> web.config
|-----> MyProject.Name (as application)
------------|-----> web.config
To do this I build it via Visual Studio Ctrl+Shift+B, then VS deploys it to IIS (creates virtual directory automatically) and that works fine.
But I have many of such projects, which are built via script using msBuild like:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe""C:\Sources\SCgit\MySolution.sln" /t:MyProject_Name /p:Configuration=Debug /clp:ErrorsOnly /verbosity:minimal
from PowerShell and it doesn't create virtual directories when builds project automatically like via VS. That's what I want.
Is there any way to tell msbuild to create such virtual directories using default pre-defined params from properties of VS project MyProject.Name.proj ?
PS
I really can't find the correct question for google, because it always redirects me to topics with a wrong value.
change of web.configs is not a good way for me, because script is a local improvement of personal performance. I need to build about 20+ projects from 10 different solutions for local development

Related

Prevent Visual Studio from automagically changing the physical path of IIS virtual directory?

I have a Visual Studio "solution" which contains a Web application project (among a few other projects). Visual studio "typical" setup seems to be to insist that the output directory for binaries is smack in the root of the project source directory. In particular, each time the web application project is opened, Visual Studio will reset the physical path of the IIS virtual directory to point to the project directory.
This is problematic on many levels:
It's never wise to mix binary output directories and source trees
If the web application is buried deep within a directory hierarchy of other source, wherein many projects produce libraries which may be used as support libraries in the web application, then all the other supporting projects must have their binary output directories set to a bin directory a some non-obvious, nonsensical location somewhere in the source tree.
This "typical" VS setup does not have your web app setup duplicate the "production" setup you would get from a publish: there may be files in your source tree (an old .js file there there from a repository extraction, for example) that are not referenced in your projects, and so would not be in the production published package, but are there in your debugging setup.
It is very possible and very easy to configure all the projects in a Visual Studio solution to build to a bin directory in some subdirectory cleanly placed outside the source tree. It is also easy to ensure that the web app build places all content cleanly in this directory. It is also easy to configure an IIS virtual directory to point to this build output directory. And then Visual Studio, unannounced and unbidden, screws this up by arbitrarily changing the physical directory of the carefully configured virtual IIS app, to point to the middle of one's source tree.
How can this crazy-making behaviour be stopped? I.e. how do I prevent Visual Studio from automagically re-setting the physical path of the virtual web directory each time the web app project is opened?
This question has been asked many times here on Stack Overflow, but I have seen no real answers:
The response to this question (IIS8.5 is automatically changing Physical Path property) simply indicates how to control the order in which Visual Studio does its repointing.
This question and response (Visual Studio creating IIS virtual directories when solution opened) simply confirm the behaviour.
The response to this question (Opening projects changes iis settings) is simply wrong, as are some of the comments.
These questions (Visual Studio 2012 changes IIS application directory without asking), (Visual Studio changes local IIS configuration) have no responses.
Basically, no one has said it can't be done, but no one has give a decent solution either.
I have my application in IIS pointed at %SystemDrive%\inetpub\wwwroot\web, and would like it to stay that way. Like others, I discovered that every time I opened the solution in Visual Studio (I'm using 2017), it would change the application's path in IIS to point to the path that Visual Studio uses.
I've made the following change to the project settings (web tab) for my project. In the servers section, I've set the drop-down to "External Host", and then entered the project URL as https://localhost/web. I'm now able to open the solution in VS without it updating the path in IIS.

WebDeployment is not

I am trying to deploy an web application that was created on VB with the .NET Framework 2.0 using the TFS 2017 continuous deploy. It doesn’t have a solution file inside like vbproj or csproj, so I needed to avoid all the suggestions to include extra information on the vbproj.In order to run the MSBuild even locally I need to change in my .sln this tag, so all my compiled code is also there
Debug.AspNetCompiler.TargetPath = "....\PrecompiledWeb\ARB\Debug\"
Unfortunately, I can’t deploy the application using the TFS. So far I tried to deploy it through my Visual Studio project, and is working fine with every option: I tried MSDeploy, Web Deploy Package, and FileSystem, and is working fine from the Visual Studio Publish Option
With that, even my transformation take place.
Now lets say I go to my TFS and I put this parameters on the MSBuild
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsASingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="\\MyServer\Content"
My files are compiled but never stored in my Content folder. No one of them!!! I can’t figure out what is going on here.
From your screenshot, you are using a Web Site project, not a Web Application project. The output structure of a Web Site project in TFS is different from build in VS (you can see a PrecompiledWeb folder in your build source directory on build agent server). Instead of using MSBuild argument, you can consider add tasks below to copy the files you want to publish:
We strongly suggest you switch from Web Site projects to Web Application projects to avoid these issues.

WCF IIS configuration and Visual Studio 2010 debug configuration

I am trying to set up my WCF service (.svc) to work in Visual Studio 2010 (pressing F5 to debug), but also to have multiple configurations for each environments (DEV, QA, UAT & Prod). When I originally built the WCF it was used purely in Visual Studio 2010 using .Net version 4 and debugging the service was easy enough by adding a WinForm application to pass in the values needed. When it was time to test the service on a server, I used the Publish feature to put the files on the DEV server and noticed that since it was using IIS that a web.config was created in the base directory.
So now that we are moving on to QA and UAT I need to make sure we have the configuration files for each environment as the Uri's change as well as various other values. Now after searching for a few days on Google, I have tried to use the XDT Transformations, but without having a third party add-in like SlowCheetah, this does not seem to work as it is only built for Web Applications. I have also tried to set up a post-build event to copy different configs:
copy "$(ProjectDir)Config\web.$(ConfigurationName).config" "$(ProjectDir)web.config" /Y
The copy process is set in the Build Events --> Post-build event command line textbox, however this does not seem to work when I use the publish method. I am ok with using multiple config files and copying them, I just have not had success with this.
The XDT makes the most sense to me and would be my preference if I could get it working. The main issue I am having is that it needs to work in Visual Studio, but also to work via IIS on the servers without having to go through a bunch of steps per environment. This is a company rule that I have to follow as well as not having a third party plug-in/add-in.
Is it possible to run the service in IIS and create a servicehost via code? I don't think it is as I believe the MSDN docs say that IIS creates it for you no matter what. Part of my reason wanting to do different configs is so that the page the user gets when they view the .svc file in the browser has the correct Uri in it not the machine name version.
TIA
EDIT: Setting up a dev web.config and including it in the project and then setting it to Build Action: Content fixes the copy method, so technically I have it working as long as I have completely different web.config files for each environment and an app.config for debugging (F5 in Visual Studio).

Web Package gets wrong IIS Website name

I'm trying to utilise TFS Team Build to deploy web applications from a solution as part of the build process, however I'm having a problem with the IIS website name when using package .zip and cmd files.
In the web application project settings "Package/Publish Web" tab I can set the IIS website name (eg "mobile") and when the project is built using the MSBuild action from the workflow the resulting .zip and .xml files are created correctly. However, upon opening the SetParamters.xml file, the IIS Web Application Name parameter has an old value, something like "Default website/mobile_deploy".
If I build a package directly from within Visual Studio 2010 the SetParameters.xml has the IIS Web Application Name I set in the project file settings.
The build template is set to clear the workspace on each build and I've confirmed this by watching the binaries folder being cleared on the build agent during the build so I'm certain its not the value hasn't been overwritten.
Any suggestions to get the project's IIS Web Application Name pulled through properly?
Maybe, when you build your project through MSBuild you don't set the same Configuration in which you have changed the IIS Web Site/application name through Package/Publish Web settings on Visual Studio 2010.
The deploy path can be different for each Project Configuration. Perhaps you set the Debug value while TFS is using Release?

How to use www root level web.Config file with "Use Visual Studio Development Center"

I hope I can explain this question sufficiently...
In the past, we have utilized a web.Config file in the wwwroot folder so multiple sites can pick up the same connectionstrings/app settings (it also allows us to have different connectionstrings on different servers, so we could publish the project without having to make changes to its web.config every time).
I'm trying to do that with Visual Studio 2010. I have a Web Project, and under Properties - Web tab, I have "Use Visual Studio Development Server" and a Virtual Path. Since it's not running under IIS, it won't pick up a config file stored in c:\inetpub\wwwroot (makes sense). Is there a way to get it to pick up such a file in this situation?

Resources