locked
Web Deployment Project Newbie with questions RRS feed

  • Question

  • User-1937378318 posted

    Hi all,

    First off all: I know this is long but I don't know how to condense this without skipping important details. Please bear with me and try to at least scan what I wrote. I am sure you can help if you have successfully used Web Deployment Projects in VS2008

    I am new to web deployment projects and I am bit confused and in need of help. I am hoping you guys can point me in the right direction for more documentation and/or help.

    I am using VS2008 SP1 under XP Pro and my primary reason for using Web Deployment Project(WDP) is the need to update web.config when a project is ready for release or testing, as well as wanting to eliminate all debug code before updating the production server. We are still using web project rather than web sites, because most of our applications are small projects for internal use only. All our web applications are installed under the default web site in a virtual directory, and run as totally independent applications.

    I am trying to build a WDP for a test application I created for just that purpose and would like to use the WDP as input for a setup project and then use the resulting MSI file to install the web application on our test server and eventually on the production server. The WDP should modify the DB connection strings in the web.config and compile everything so it can be installed as a web application in a virtual directory under the default website. So I set the following options in the WDP Property pages:

    Compilation page: Output Folder is .\Release\ and "allow this precompiled Site to be updatable" is checked.

    Output Assemblies page: Merge all outputs to a single Assembly is selected and I left the default name. Under Merge Options I set the version numbers to 1.1.1.1 for both Assembly and file 

    Signing page: nothing is set here

    Deployment page:Enable web.config file section replacement is checked and I entered

    connectionStrings=ConnectionString.config

    in the field and I checked the "use external configuration source file" option. I also checked " Create an IIS virtual directory for the output folder, entered a name for the directory and checked " Replace existing Virtual Directory". I also checked the "Remove the App_data folder from output location" option.

    That's it for my settings.

    I created a file called ConnectionString.Config and copied the connectionStrings section from a production website to make sure the XML is correct. The file is stored in the WDP project directory. And that brings me to my first question:

    Is there some way to "Add" files/items to a WDP, so that the file appears under the project in Solution Explorer the same way other files are added to projects? Or how do you make sure that whoever next works on the WDP knows which files are needed to build the WDP? Right now there is nothing that indicates there is a connectionStrings.Config file outside of the Deployment page. Where should those files be located - under the WDP or under the Web project?

    When I build the WDP using the release configuration I get no errors but 1 warning and the output is: 

    Rebuild All: 0 succeeded, 1 failed, 1 skipped


    The skipped project is the web project, because for the Release configuration I don't build the web app. The failed project is the WDP I would assume, but the output window shows:

    Done building project "TestSelectedValue.csproj_deploy.wdproj".

    SO that looks like the WDP was build, doesn't it? Since that is the only project build for Release, which one failed?

    Again, there are no errors, just one warning which is:

    aspnet_merge : warning 1013: Cannot find any assemblies that can be merged in the application bin folder.
    Successfully merged '.\TempBuildDir'.

    Again, that looks like it worked.

    The connection string element got updated in the web.config file just fine. The web.config file now shows:

    <connectionStrings configSource="ConnectionString.config" />

    So what failed?

    It must be the WDP because according to the documentation I found here:

    http://msdn.microsoft.com/en-us/library/aa479568.aspx.

    I am missing some files that should have been created when the WDP was build.

    And that brings me to these questions:

    Why is there no Release.Config file in the WDP Release directory?

    Why is there no App_code.Compiled file in the WDP Release/bin directory?

    Why is the .pdb file included although the web.config file in the release directory shows:

    <compilation debug="false">

    Please, can anyone help me out here?

    Finally, if I ever get this WDP to build I need to use it to build a web setup project. Can anyone point me to some documentation that shows an example for doing that? I only found a blog that said you can "pipe the WDP to a web setup project" but nothing about how to do that.

    Any help is very much appreciated, even if you know only part of the answer to one question you already know more than I do and I hope you will reply.

    Thanks bunches

     

     

     

    Thursday, April 15, 2010 3:25 PM

All replies

  • User-1916342745 posted

    You're right, this is a long post!

    Assuming that changing to 2010 is not an option (there is a new config translation language/tool) which would pretty much solve your problem. 

    I don't use WDP (couldn't see it in pro version). 

    that said... you could create a basic web.config, and reference other sections in a sub folder. 

    so for example in the main web.config you'e reference connection strings as follows:

     <connectionStrings configSource="configFiles/connectionstrings.config">
      </connectionStrings>

     <connectionStrings configSource="ConfigFiles/connectionstrings.config"></connectionStrings>
    
    

    The connectionStrings.config files would be located in a folder of the project called ConfigFiles:

    <connectionStrings>
    
      <add name="test1" connectionString="datasource=remote"/>
    
    </connectionStrings>

    I'd then duplicate this folder for each environment. i.e. create a new folder called ProductionConfigFiles, It would have the same files, and just change the relevant parts.

    I'd then create a main msbuild event, which builds the solution, but then copies over the productionConfigFiles renaming it to ConfigFiles for the release. 

    Sorry that this doesn't give you the solution you were looking for, but might help you with a couple of alternative options. 




    Friday, April 16, 2010 6:49 AM
  • User-1937378318 posted

    Thanks for the reply Romage!

    I am about to give up myself on this, because things are getting worse not better. I am now getting a bunch of error messages that I don't understand because everything is back to the way is was after I made a change and then undid that change.

    Anyway, about your reply: You say you create a main msbuild event that builds the solution and copies the config files after the solution has been build. To be honest I have been thinking about those lines myself. Since WDP is just a wrapper for a bunch of msbuild events, why not use msbuild directly?

    But where did you put that main msbuild event? And how can I get all this into a setup project so I have an install package to run on the server when it is time to release a specific configuration?

    Obviously I know nothing about msbuild either. Perhaps you can give me some pointers to get me started? Where can I find good documentation about msbuild?

    Finally, you say that you don't use WDP because you could not see it in the Pro version. What  do you mean by that?

    Assuming you mean Visual Studio 2008 Pro, you should be able to use WDP once you installed the add-in, which is free and can be downloaded from Microsoft. Did you install the add-in?

    Or is it that you could not find WDP in the list of project templates when you tried to add a WDP project to your solution? To add a WDP to your solution you have to select the "Add WDP Project option" on the Build menu to create one.  

    Thanks again for your reply. I look forward to reading your reply to my reply.

    Friday, April 16, 2010 12:06 PM
  • User-1916342745 posted


    Hi there.

    There used to be a good video on this site about msbuild, but I couldn't find it just now when I looked (thought its probably still around). 


    1st) add a shortcut to msbuild 

    Tools-> External tools -> add

    Name: msbuild

    Command (default directory is as follows): C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe

    Arguments: $(SolutionDir)\Build.build

    Initial Directory: $(SolutionDir)


    2nd) Create a new build file. This would live in the root of your solution. This is basically an xml file. I don't think the extension is important, but I normally use .build or .proj or something. 

    Right click on the solution -> add new item -> xml file (call it build.build)

    remove the default contents of the file and add:

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"  >
    </Project>

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"  >
    
    </Project>


    After this you should get full intellisense. There are  load of resources on the internet about creating these. Its a good idea to look at the existing project and solution files which are effectively build files. 

    One slightly confusing thing is that there is also an event which is msbuild (it takes solution or projects as one of the paremters). 

    you can then build the project by going to Tools -> msbuild (which is the new item you added as an external tool). 

    I'm no expert at these files. You might find a load of additional resources, buy looking into "continuous integration", "Cruise Control", "Nant", "Team City", "Final Builder" or "Team Foundation Server"  etc, as these all deal with depoloyment issues. 

    Finally I'd recommend looking into VS2010 as this is one of the big areas which has been improved. You may find the following link about web.config transformations interesting: http://go.microsoft.com/fwlink/?LinkId=125889.

    best of luck





    Friday, April 16, 2010 1:04 PM
  • User-1937378318 posted

    Hi there,

    I am with you almost all the way. I got the tool added and the XML file created but when I replaced the default content with the project tag line you have in your post, I got an error saying that the project element in http://schemas.Microsoft.com/developers/msbuild/2003 has incomplete content and I got a list of possible expected elements.

    Can you tell me what I messed up? I copied the code from your post to make sure I did not introduce a typo.

    I may be able to upgrade to VS2010 but only if it can run side-by-side with vs2008. Determining that is my next task, I hope. Perhaps I will try WDP again when we switch to vs2010, but for now I am to frustrated to continue with it. I still have not been able to get a clean build although I am not getting any errors at all. And I have no clue how to use the output from the WDP as input for the setup project. All of this would not be a problem if I could find some documentation for WDP that is current. It is so frustrating to be stuck like that and get nowhere.

    So I will try to do this with msbuild and see how far I can get.

    One more question: Can I call msbuild from a setup project?

    I am imagining this scenario: Have the setup project call msbuild to modify the web.config file so that I can compile without debug code,  replace the connection strings and do whatever else I need to do. Then the setup project would build the install package using the modified web.config.

    That what I wanted to do with WDP and will need to do using msbuild or there is not much of a point to use either one.

    Thanks again for your help

    Friday, April 16, 2010 2:17 PM
  • User-1916342745 posted

    Firstly, you didn't mess up, I only included very, very, very basic instructions to get started. You'll need to do some more hunting to get it working. 

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="Build2">
      <Target Name="Build1">
        <MSBuild Projects="MvcApplication5.sln" />
      </Target>
      <Target Name="Build2" DependsOnTargets="Build1">
        <Copy SourceFiles="**.*" DestinationFolder="c:\projects\test25" />
      </Target>
    </Project>

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="Build2">
    
      <Target Name="Build1">
    
        <MSBuild Projects="MvcApplication5.sln" />
    
      </Target>
    
      <Target Name="Build2" DependsOnTargets="Build1">
    
       </Target>
    
    </Project>


    I just did a WDP project, and I don't think I'll bother again. Far too much work for too little gain. Other options are better. 

    MsBuild is already being called from the setup project. The sln/proj files are effectively msbuild files. The WDP expects the primary output from the projects which runs MSBuild (project files), and collects the created Dlls.  However I can't see this working with my quick add-on msbuild file on the root of the solution. 

    vs2010 sits side-by-side vs2008. However when you open a 2008 project in 2010, you'll be asked to convert it. You can keep targeting the original framework (2.0, 3.0 or 3.5) or you can try to upgrade to 4.0.  Once you've converted, I don't know of an easy way to open the project again in vs2008. 

    I've just done a quick publish/deployment in  2010 (am using professional version), and it took about 30 seconds to setup, and run. It really is very easy. You can make it go straight to IIS, or copy to a file location, or build a zip file with necessary config stuff. You can even get it to deploy the database scripts at the same time. 




    Friday, April 16, 2010 4:31 PM
  • User-1937378318 posted

    Firstly, you didn't mess up, I only included very, very, very basic instructions to get started. You'll need to do some more hunting to get it working. 

     Now that I see your build file, it makes perfectly good sense. And you are right, WDP does not seem to do much more, especially since I still can't get my project to build. :-)

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="Build2">
      <Target Name="Build1">
        <MS-Build Projects="MvcApplication5.sln" />
      </Target>
      <Target Name="Build2" DependsOnTargets="Build1">
        <Copy SourceFiles="**.*" DestinationFolder="c:\projects\test25" />
      </Target>
    </Project>

    Ms-Build is already being called from the setup project. The sln/proj files are effectively ms-build files. The WDP expects the primary output from the projects which runs MS-Build (project files), and collects the created Dlls.  However I can't see this working with my quick add-on msbuild file on the root of the solution. 

    This is starting to look a lot like Makefiles from back in my Unix/C days...

    Supposedly there is a way to use WDP and Setup projects so that the setup project uses the output from the WDP to create the install package. That's why the documentation says not to compile the project when you build the WDP, because the project will be compiled by WDP and web.config files will be modified according to your specifications and then the setup project uses the modified files from WDP to create the Install package. At least that is how I understood it.

    However, I think I will follow in your foot steps for now and create a build file to replace my connection strings and then just gather everything I need in a .zip archive to get it over to the servers. I am sick and tired of banging my head against WDP and get nowhere with it.

    vs2010 sits side-by-side vs2008. However when you open a 2008 project in 2010, you'll be asked to convert it. You can keep targeting the original framework (2.0, 3.0 or 3.5) or you can try to upgrade to 4.0.  Once you've converted, I don't know of an easy way to open the project again in vs2008. 

    That sound sounds just like vs2005 side-by-side with vs2008. Some setup for those 2 as well. I have a MSDN subscription, so I just have to wait for the CD to arrive which should be soon. Maybe I will try WDP one more time when I have vs2010 installed.

    Until then I will educate myself about MS-Build and see what I can do with that. Maybe I can call a build file as a custom action in a setup project and handle the connection strings that way...

    It's Friday, late in the afternoon and I will call it a day.

    Thanks for all your help romage, I don't know if I would have survived the day without your help today and I hope I can return the favor one day.

    Have a great weekend!




     

     

     

     

    Friday, April 16, 2010 6:40 PM