1

This question could be considered an update of one from two years ago asking how to publish from an open ASP.NET Core solution in visual studio 2015 (then called ASP.net vnext and briefly also known as ASP.NET 5) to another machine on my local network, which has IIS deployed on it, and which should be used to run the DNX runtime and the ASP.NET application I am writing. Since the wizard provides no help for me, I believe I will have to completely manually configure either an MSDEPLOY solution and its configuration files, or something else equivalent to it.

The situation has changed a lot since that original question, so I am asking for ASP.NET 5 and DNX 1.0 RC1.

There are some related other questions that ask how to do this and mentions WebDeploy 3.6 and is also referring to nearly 2 year old beta releases,.

I believe therefore, that this question should have a new and different answer for Visual Studio 2015, now that ASP.NET 5 is at the release candidate and is feature complete. How is it done now?

Also it should be made clear I'm not talking about deploying from my Visual Studio solution on C:\DEV\WORKINGCOPY to my own machine's c:\inetpub\wwwroot, but rather copying across a network, either via web-dav, or FTP or SMB share, to a windows Server box running IIS.

What I have tried so far:

  • Use the built in Publish To Web wizard in filesystem mode. The result seems to be something you could run via a web.cmd which will execute dnx and kestrel, but does not build a bundle that is runnable from IIS 8.x on Windows Server 2012. Furthermore, the publish to filesystem mode creates a bunch of stuff including a basic set of folders named approot, logs, and wwwroot, and I am pretty sure that IIS should not be set up to serve up the approot or logs folders directly. If I look at my copy of the wwwroot\ folder from IIS, I see a 500 - Internal server error. That's what I'd expect IIS to do when it has no idea how to take the web.config in there and do anything with it.

  • Tried to use dnu publish and dnu pack manually from a command prompt, with the idea that perhaps I could use the results to replace the contents of my XYZ-publish.ps1 powershell file PublishProfiles. dnu publish command fails with "bower not recognized as internal or external command". dnu pack succeeds, but I have no idea what to do with the resulting .nupkg files with regards to getting them to run on IIS.

My goals in general are:

  • To have everything done in one click or by typing one command, including any bundling and building of any pre-compiled-assemblies (nuget packages being the vNext equivalent concept to Assemblies inclassic .net).

  • To make clear to myself and other readers what the one time set up tasks on IIS are before you are ready to deploy, and what the tasks are that are done for you each time you click publish, and how to set them up.

This appears to be a fundamental area where the documentation on ASP.NET 5 at this time is extremely weak, and the tooling is currently optimized only for people who want to deploy a bundle to a folder and run it from "dnx web" (kestrel), or for those who want to deploy on Azure (this process is fully automated for those cases within the Publish wizard) not those who want to deploy to their own machine running IIS. The publish wizard is missing this extremely obvious (to me) case; Publish to a Windows server box of my own, and create me any IIS scaffolding that I need to get this working.

Community
  • 1
  • 1
Warren P
  • 65,725
  • 40
  • 181
  • 316
  • If downvoters could point out what is wrong with this question, it would be appreciated. – Warren P Jan 06 '16 at 19:30
  • The bower tool appears not to be distributed with visual studio. To get it install NodeJs then type `npm install bower -g` to get bower installed and accessible as a command line tool in your path, you might have to manually add `c:\users\youraccountname\appdata\roaming\npm` to your path – Warren P Jan 06 '16 at 19:54
  • 1
    I think the idea is that you combine those things via a script. IOW, you create a script that runs bower/npm/gulp etc. then does a dnu publish to either a local or network location and optionally publishes from there. The IIS story today totally sucks though. It's a pain to get DNX apps ruinning on IIS currently. I suspect this will get addressed in RC2 with the new tooling though and if not then for sure by release. – Rick Strahl Jan 07 '16 at 10:25
  • Good, they had better improve this tooling, because it currently sucks. But I want to get it working NOW so I can get my development team doing continuous delivery, so I'll do the learning and figure out a solution and document it here. One thing not addressed in my provisional answer below is "getting DNVM/DNX/DNU tooling and dependencies installed in a context where they become visible/usable/operable within IIS". – Warren P Jan 07 '16 at 20:16

1 Answers1

2

Update: Microsoft's Connect 2015 demo suite called Healthcare.biz contains a powershell based deployment scenario (for azure) that could probably be adapted to a local IIS server. See the PublishAspNet5Website.ps1 powershell script at that GitHub repo.

There are many elements to this question and I could not find any one source that identified them all.

  1. First some setup on your IIS Server is required, as per this question, you must select the app pool that will be used to run your DNX/ASP.NET 5 application. You should also create a virtual folder and then convert that into an Application. According to that linked question you should be using a .NET 4 pool. Additional setup on your IIS Server may include setting up server side tooling to accept incoming publish requests from your visual studio (inside IDE) and msbuild command line (continuous integration server) deployment tooling.

  2. Because the wizard that comes inside Visual Studio 2015 (including the one in update 1) does not offer a choice like "Deploy to a Windows Server on your domain", you will have to study the existing options, like the file-mode deploy option and the azure deploy option and choose some hybrid approach based on one of those two starting points. Your assets include all the power of powershell, and all the power of the dnx/dnu tooling, including its bower integration. You will bundle/build/compile as needed, and then send the results along to MSDEPLOY tool, which you will then need to write configuration (.pubxml) files for. You also have the option of ignoring the DEPLOY command entirely and choosing to deploy via a "staging" verb you add to your dnx project, to deploy to a staging server.

  3. In order to have any hope of modifying the meager starting file set into the condition required to do the job specified in the question, you will probably have to read the documentation on MSDEPLOY. Searching around on the internet I have found that there are some example .pubxml files here and there that show how the .pubxml is constructed. Inside your deployment profile folder, you will need at least one properly constructed .pubxml file, and another file with the same base name, and the extension .ps1 (powershell) instead, which appears to be the same no matter which technique you use, so the only reason why it can exist in my view is so you can accomplish other tasks within that powershell.

Sample .pubxml content

<?xml version="1.0" encoding="utf-8"?>
<!--
 NOTE: I'm pretty sure that the publishprovider should NOT be the one shown here. 
 I do not know what it should be and will update this answer when I figure that fact out.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <ADUsesOwinOrOpenIdConnect>False</ADUsesOwinOrOpenIdConnect>
    <PublishProvider>AzureWebSite</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>http://ramsoftazurewebappdemo.azurewebsites.net</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <CompileSource>False</CompileSource>
    <_DefaultDNXVersion>dnx-clr-win-x86.1.0.0-rc1-update1</_DefaultDNXVersion>
    <UsePowerShell>True</UsePowerShell>
    <IISCommand>web</IISCommand>
    <WebRoot>wwwroot</WebRoot>
    <WwwRootOut>wwwroot</WwwRootOut>
    <IncludeSymbols>False</IncludeSymbols>
    <Native>False</Native>
    <IgnoreDNXRuntime>False</IgnoreDNXRuntime>
    <MSDeployServiceURL>myservername.mydomain.biz:443</MSDeployServiceURL>
    <DeployIisAppPath>MyWebAppPath</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>$USERNAME</UserName>
    <_SavePWD>True</_SavePWD>
    <_DestinationType>AzureWebSite</_DestinationType>
  </PropertyGroup>
</Project>
  1. It might not hurt to become familiar with the commandline options available for MSDEPLOY directly, which you could invoke yourself, from that powershell ps1 script, instead of using the .pubxml format. Here is a sample of how MSDEPLOY.EXE (also called Microsoft Web Deploy V3 online when you are looking for documentation) gets invoked:

.

  "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" 
  -source:IisApp='C:\dev\PublishOut\YourWebApp\wwwroot
   -dest:IisApp='YourIisAppName',
     ComputerName='https://yourcomputername.yourdomain.biz/msdeploy.axd',
     UserName='$USERNAME',
     Password='secr3t',
     IncludeAcls='False',AuthType='Basic' 
   -verb:sync -enableLink:contentLibExtension  
   -enableRule:DoNotDeleteRule -retryAttempts:3
  1. If you haven't tried them yet, get used to the dnu pack and dnu publish options within the vNext dot net utility (dnu) command. This is how you get your ASP.NET source files bundled up, along with a copy of the DNX runtime, so that it's ready to run on the server side. For me, I could not use the dnu publish command which appears to be a client-side resource publishing stage which depends by default on the node.js (javascript) tool called bower, which I found I had to install manually as Visual Studio 2015's asp.net 5 templates depend on this tooling but do not seem to install it by default (maybe I just missed an option when I installed visual studio, I'll update this answer if that's the case).

I will continue to refine and expand this answer as more details come together. I am currently following through tutorials that discuss only how to do this when deploying to azure or to commercial internet hosting concerns, and I will attempt to adapt them to in-house servers, where you're also responsible for the configuration of the IIS server and any publish-agent software that must be configured on the IIS server as well.

Community
  • 1
  • 1
Warren P
  • 65,725
  • 40
  • 181
  • 316