Project contained IIS Express - iis-express

I am looking for a way to make IIS Express contained within a project along with other tools project requires and being able to run project from that self-contained IIS Express. It looks like IIS Express stores settings under user specific %MyDocuments% folder, which doesn't help for my goal (CI eventually).
Thank you.

If you don't want to rely on %mydocument% folder, you can provide your own applicationhost.config file(which contains all your settings) to iisexpress.exe with /config command line switch.
Following link may help you http://learn.iis.net/page.aspx/870/running-iis-express-from-the-command-line/

Related

Visual Studio Publish Profile: Delete specific folder on the server before publishing

Is there a way for a Web Deploy operation to Azure App Services to delete a specific folder on the server before the deployment starts?
I need certain files to be removed on the server when they are removed on the solution and deployment leaves those files intact on the server which is causing issues.
Is there any way to add this to the publishing profile as a pre-publish action?
Just to add more context, this is an ASP.NET project using C#. Sitecore is the CMS.
i have tried to find something specific to the SiteCore and not msbuild BeforePublish target, but it looks like you have two options here:
1) Use msbuild BeforePublish target
2) Use Visual Studio Team Services build Continuous Integration - it will need some additional manual tasks, but nothing serious and it is much more visual than msbuild.
I would highly recommend to try the second option - here, you can specify build steps like Take sources => build => execute some command (here is your place to put something for deleting the files) => publish.

How do I specify the location of IIS Express runtime for SharpDevelop?

I don't have admin rights on my machine, so I can't install IIS Express with the wizard, so I have unpacked the installer into a folder.
I can edit the applicationhost.config manually and it runs exactly as I should, but how can I tell SharpDevelop (4.3) where it is?
When I switch to the Web tab on the project properties it tells me
Local IIS or IIS Express was not found.
and the only option I have is to Disable web server options.
Am I missing an option, or is there a (HKCU) registry setting I can tweak?
Ben
Unfortunately it is not currently configurable. Currently SharpDevelop looks for the IIS Express executable in program files.
You could try setting the project's properties so it uses IIS Express as a startup program. This can be configured if you select the Debug tab in the project properties.
Alternatively you could download the source code and edit the WebProjectService class to use the correct path.

IIS Express on a shared development machine (rdp)

I have a problem which I thought could be common, searched the web for it but found nothing.
We're using a shared development machine, and every developer connects through RDP and has his own profile, desktop, etc.
The problem I am encountering is with IIS express. Since it is configured at user level (applicationhost.config inside documents/iisexpress/config) and the port configured must match the one declared in the .csproj file, two developers can't possibily run on the same port, as it gives the error "the port is already in use".
So to make it work we have to manually change the port both on the csproj and in the applicationhost.config for every developer, but it's only a temporary fix as when we commit our changes to SVN, the csproj file gets merged, so we have to do this process every time someone commits/updates.
My question is: is there a clean way to use IIS express with Visual Studio 2010 on a shared development machine?
Thanks.
Partially tested answer. Not sure how it'll work on a multi-user workstation. It might give you, or someone else here, a jumpstart to a proper solution that works best in your existing environment.
It appears that Visual Studio stores all the web configuration in the csproj/vbproj and IISExpress stores its configuration in %userprofile%\Documents\IISExpress\config\ApplicationHost.Config.
Normally, we store the csproj files in source control, but ignore the csproj.user file so that each person may have some unique settings, such as the web configuration.
Each user who signs into the box must have their own profile.
Each profile must have their own copy of the source code.
Each user's copy of the source will contain their own csproj.user file.
Ignore .**proj.user* files in your source control.
Copy the web settings into the csproj.user by unchecking the option Apply server settings to all users and then commit to source control.
Each user who pulls a copy of the source will have to configure their web settings, use a unique port that the others users are not using, and uncheck the box above so that their configuration is not passed on to the other users.
Doing this, Each profile will have their own IIS Express ApplicationHost.Config configured with a port that is different from the other profiles. Each user's copy of the source will have a csproj.user that is configured with the same port in their profile's IIS Express configuration.
For reference:
I've tried changing IIS Express's ApplicationHost.Config to use a different port than what Visual Studio expects and Visual Studio is unable to connect the debugger to IIS Express.
How IIS Express's configuration works: http://msdn.microsoft.com/en-us/library/ms178109.aspx
The best option you can use is to take advantage of the Import functionality built into MSBuild.
Essentially, you would create a seperate build target for each user. You can then import this target from this referenced file directly. I would then recommend creating this file on the server (for each user), but leaving it outside of source control.
This should allow each user to have a custom IIS port without conflicting with others.
I think you can create subdomains for each user and implement the required changes and do the testing. In this way each user can his own subdomain and port and hence work independently on the shared IIS Express.
You probably won't like my answer but here's my thoughts:
As you noticed, the configurations are tied to the user profile and not the server; this is because IIS Express is not intended to be used as a shared development server. You should be using full IIS.
I do not see any benefit or reason to use the same physical box for development. Admittedly, I don't know all the details of your scenario with licensing or workstation resources, but it doesn't seem like you gain much from having everyone RDP into the box to use Visual Studio - each person still needs a license, performance will be slower, and you shouldn't be working on the same project instance.
You should seriously consider your entire setup for development:
Each developer should use Visual Studio on their workstation, and debug/test there using IIS Express (configured with the same ports and settings across all machines - very easy).
From there, your developers should check their code into source control, and examine conflicts that may or may not arise. I'm not sure about SVN but the MSBuild automation available in TFS can be use to setup a continuous build policy that deploys to a common IIS installation so that your merged code is tested and usable from the full IIS installation mentioned above.
Anything else would be a workaround/hack that will bite you in the butt later.

IIS Express unable to create the virtual directory

I'm using IIS Express to create a virtual directory at http://localhost:5000/ and received this error:
Unable to create the virtual directory. The URL http://localhost:5000/ is already mapped to a different folder...
This is because I've used the port 5000 for an old project before and it's no longer needed.
My question is, how can I remove the old mapping using IIS Express so I can create the virtual directory at the same port again?
Thanks
You should be able to accomplish this in one of two ways.
You can remove the old project, or change its port using WebMatrix, which has an administration interface for IIS Express.
You can also do it by hand, by modifying the applicationhost.config file directly. The file is located in the %userprofile%\documents\IISexpress\config folder. You can find the project configuration under the <system.applicationHost>/<sites> element.
UPDATE:
WebMatrix has been discontinued and support has officially ended.
No software installation required. Simply follow the steps:
Right-click the project node in the solution explorer and select the option to edit the project (.csproj) file. Near the bottom of the file, find the following:
<iisurl></iisurl>
Edit this entry to add your virtual directory:
<iisurl>http://localhost:5000/</iisurl>
I was getting this because I had a site on the IIS Server (not express) with the same bindings (domain name and port) as IIS Express was trying to use.
I thought that since the site was not started it would ignore it, but I was wrong. Once I change it in IIS, then the IIS Express one worked and the error went away.
Seems you need to run Visual Studio with administrative rights if you want to create Virtual directory on ports below 1024.

Problem after publishing web application from VS 2010

Whenever I publish my MVC web application in VS 2010 via the One-click publish feature (I'm not doing any web.config transforms or anything fancy - yet!). The next time I come to build the app I get the following error:
It is an error to use a section registered as allowDefinition='MachineToApplication'
beyond application level. This error can be caused by a virtual directory not being
configured as an application in IIS. in ...MyWebApp\obj\release\package\packagetmp
\web.config
A new copy of the web.config file is indeed created by VS2010 below the ...MyWebApp\obj\ folder so I deleted the whole obj folder and I was then able to build again.
But I shouldn't have to do that each time I publish - I must have something configured incorrectly - can anyone help please.
Thanks.
This is unfortunately a known issue with Publishing a web application to the file system. This still affects the release version (RTM) of Visual Studio 2010. It's not limited to the Beta or RC versions.
This problem "bit" me also, and I too was having to manually delete the Debug and Release folders inside the obj folder within my web site solution folder.
The real answer for an automated "workaround" can be found in this answer to the other Stack Overflow question:
Why do I randomly get a “error to use section registered as allowDefinition='MachineToApplication'” when building an MVC project?
In a nutshell, you need to delete the web.config files from either the Debug or Release folders (or both!), and that's achieved with a pre-build command (configured in the Build Events tab of the Project Properties page of your solution):
del "$(ProjectDir)\obj\Debug\Package\PackageTmp\web.config"
del "$(ProjectDir)\obj\Release\Package\PackageTmp\web.config"
Personally, I delete the entire obj folder since all those files are re-created with each build anyway.
I have just found a work around for this that has worked for me, open the .csproj for your web project and change the node under the Project\PropertyGroup node to this:
from this:
<MvcBuildViews>true</MvcBuildViews>
to this:
<MvcBuildViews>false</MvcBuildViews>
This has worked for me, hopefully it will work for you also.

Resources