Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:40:27+00:00 2026-05-16T14:40:27+00:00

Are there good patterns for mapping solution configurations to environments and using MsDeploy for

  • 0

Are there good patterns for mapping solution configurations to environments and using MsDeploy for packaging per environment?

Shortest version: Grab this file, and try to change the .msbuild file so that a package is created.


Details

I have a solution with a large number of libraries and an ASP.NET MVC application. I drive the build with an msbuild file that calls the main solution and then does other things. I want to use the new msdeploy packaging to prepare a .zip file for later distribution, but I’m having various difficulties.

My solution has 4 configurations: Local, Dev, Test, and Prod, which match the environments I want to map to. In that solution, all of the libraries have Debug and Release modes like usual. For example, in Local solution mode, all libraries compile in Debug mode. Then, the main application has matching environments with the solution, so that I can have Web.Dev.config and so on, which seems like the natural way to use things.

If I package like this:

<Target Name="BuildWebPackage">
  <MSBuild Projects="..\Publisher\Site\Site.vbproj"
           Targets="Package"/>
</Target>

I get a problem where the Configuration=Local is incorrectly mapped down to the library projects that Site.vbproj references, and it can’t compile them.


I see two possible solutions: one I can’t get to work right, and the other is extremely ugly.

Attempt 1

I attempt to call the Package target via the solution (in this example, “Applications” is the solution folder that the Site project is in… I’ve simplified things down for this post because there are actually multiple applications in the solution.)

<Target Name="BuildWebPackage">
  <MSBuild Projects="..\Publisher\Publisher.sln"
           Targets="Applications\Site:Package"/>
</Target>

I think this SolutionFolder\ProjectName:Target syntax is how to do this, because :Clean runs… however, this throws

error MSB4057: The target "Applications\Site:Package" does not exist in the project.

Attempt 2

Now for the ugly solution: it works if I modify ALL my libraries to have 4 additional configurations for those 4 solution configurations. However, this is ugly and really a bad plan if I want to co-develop a shared library later with a project that has different environments. Also, those environments have nothing to do with the library and only make sense in the context of the top-level applications using the libraries. Tastes bad.


Huh?

I like having the multiple environments in the solution, and the fancy new Web.config replacement stuff, but I don’t know how to call the msdeploy Package task in this situation so I can build the package in TeamCity.

(Note that I probably do NOT want to call the msdeploy command line, because that’s used to turn an IIS app into a package. Not what I’m doing here.)


Sample

Again, I’ve been completely stumped here, so if you want to help experiment, I’ve put together this sample solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:40:28+00:00Added an answer on May 16, 2026 at 2:40 pm

    The first attempt failed because Package target doesn’t exist in the solution file. When using MSBuild on a solution file, a temporary MSBuild project is created (SamplePackage.sln.metaproj); this project file contains only some targets (Build, Clean, Rebuild, Publish, …)

    Solution : DeployOnBuild & DeployTarget properties

    One way to do what you want is to use DeployOnBuild property like this :

    <PropertyGroup Condition="'$(Configuration)' == ''">
      <Platform>Any Cpu</Platform>
      <Configuration>Dev</Configuration>
      <PackageLocation>$(MSBuildProjectDirectory)\package.zip</PackageLocation>
    </PropertyGroup>
    
    <Target Name="Build">
      <MSBuild Projects="SamplePackage.sln"
               Targets="Build"/>
    </Target>
    
    <Target Name="BuildWebPackage">
      <MSBuild Projects="SamplePackage.sln"
               Properties="Platform=$(Platform);
                           Configuration=$(Configuration);
                           DeployOnBuild=true;
                           DeployTarget=Package;
                           PackageLocation=$(PackageLocation);"/>
    </Target>
    
    • DeployOnBuild=true : deployment must be made when Build is called
    • DeployTarget=Package : for deployment creates a package
    • PackageLocation : indicates the filepath of the package file

    Additional links :

    • Creating web packages using MSBuild
    • How can I get TFS2010 to run MSDEPLOY for me through MSBUILD?
    • How to "Package/Publish" Web Site project using VS2010 and MsBuild
    • Automated Deployment in ASP.NET 4 – Frequently Asked Questions
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's very simple. Your DSN is flawed. Use this: $this->_connection… May 16, 2026 at 3:50 pm
  • Editorial Team
    Editorial Team added an answer I'll give you 2 answers: first, check out this link:… May 16, 2026 at 3:50 pm
  • Editorial Team
    Editorial Team added an answer The problem here is not that you can't add an… May 16, 2026 at 3:50 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

For methods where ... there exists a static one-to-one mapping between the input and
Are there good references teaching you how to send PUT/DELETE/POST/GET with ruby? I have
I used to work with a custom data mapping library, and curently I'm trying
In my Django project, my url.py module looks something like this: urlpatterns = patterns('',
I need to store some data that follows the simple pattern of mapping an
I have a button with 3 States Start/Resume/Pause. 1 Is this a good pattern
I have the understanding that using data access routines directly from presentation code is
I am looking for a good design pattern, or best practice to achieve a
I'd like ask a question about building applications in .NET that use data from
Almost every game use keyboard as input. I have been searching for 2 days

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.