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

  • SEARCH
  • Home
  • 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 4599296
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:31:14+00:00 2026-05-21T23:31:14+00:00

Problem : I want to elegantly publish an MVC website with NAnt. Simple no?

  • 0

Problem: I want to elegantly publish an MVC website with NAnt.

Simple no? Wrong… Here are some of the stackoverflow resources I’ve looked at. Each one of them has an issue…

Stackoverflow 1:
Publish WebApplication using NAnt

The result of this one was that the web.config was not being transformed and additional files were showing up in the bin that weren’t suppose to like the entity.dll.config of all things!

Stackoverflow 2:
Replicate VS2008 "Publish Web Site" from command line

This one will do the same as the previous solution except it’s even worse… it will copy EVERYTHING from my project and dump it into the publish folder… no joke!

Stackoverflow 3:
MSBuild Script and VS2010 publish apply Web.config Transform

The accepted solution builds on top of Stackoverflow 1, but is pure MsBuild xml and not NAnt xml. It also only fixes the Webconfig and so still leaves those random files that show up. There is also another solution (not accepted) that pattersonc gives, which is very, very close to correct but the connection strings in the web.config are in a bogus limbo state, leaving you with yet another bad web.config

Needless to say it’s been 3-4 days, 10+ different StackOverFlow answers and no silver bullet… Is there no easy solution? Must I commit some cardinal sin and create some horribly messed up NAnt script to achieve the correct publish results that VS2010 delivers so nicely?

  • 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-21T23:31:15+00:00Added an answer on May 21, 2026 at 11:31 pm

    Okay I figured it out after chancing on this blog,
    http://blogs.msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx

    In step 4 he shows a command line arg I haven’t seen before,
    /t:TransformWebConfig

    Unfortunately, this alone does not solve the problem. It does perform the transform but the transform is found in obj/Release/TransformWebConfig/transformed/Web.config (obj/Release or obj/Debug or obj/YourTranformName).

    So to finally get a decent solution this is what I had to do.

    <exec program="${exec.msbuild}" failonerror="true">
        <arg value="${path.sourceCode}/ProjectFolder/Project.csproj" />
        <arg value="/p:Configuration=Release" />
        <arg value="/t:ResolveReferences" />
        <arg value="/t:_CopyWebApplication" />
        <arg value="/t:TransformWebConfig" />
        <arg value="/p:OutDir=${path.buildFromProject}/temp/" />
        <arg value="/p:WebProjectOutputDir=${path.buildFromProject}/ProjectBuild/" />
    </exec>
    
    <delete dir="${path.build}/temp" failonerror="true"/>
    <delete file="${path.build}/ProjectBuild/Web.config" failonerror="true"/>
    <delete file="${path.build}/ProjectBuild/Web.Debug.config" failonerror="true"/>
    <delete file="${path.build}/ProjectBuild/Web.Release.config" failonerror="true"/>
    <copy file="${path.sourceCode}/ProjectFolder/obj/Release/TransformWebConfig/transformed/Web.config" tofile="${path.build}/ProjectBuild/Web.config" />
    

    Notice that the OutDir is not the same as the WebProjectOutputDir. This is the reason why:

    • OutDir gives you everything in the
      project “solution”.
    • WebProjectOutputDir gives you the
      bare minimum for the web “project”
      (i.e. not the entire solution).

    A lot of extra baggage was coming over from other projects in the solution using OutDir that we didn’t want so we just sent OutDir to a temp folder and deleted as you can see in the steps above. OutDir is absolutely required by the way. The build will not work if you remove it. Seems that WebProjectOutputDir works off of OutDir.

    There is only one minor flaw with this entire setup. A lot of pdb files are missing from the bin library. The only pdb copied over was the one from the Web project.

    If anyone ever finds a one step solution with MSBuild to this please post it : P
    Although this is a good solution it is still only 99.9999% perfect and much like the ones listed above I’m sure there’s going to be some little nuance or step missed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I want to list n number of games from each genre (order not
Really simple problem: I want to split a connection string into its keyword /
I have a simple problem: I want to construct a regex that matches a
Problem: I want my unicode characters to be stored on disk as (rather tan
Problem: I want disparate sections of my code to be able to access a
Problem I want to create an application that can be extended somehow by programmers.
Problem: I want to put Twitter Share Button in my Google Map InfoWindow. I
Core problem: I want to be able to take an instance of a templated
Following problem: I want to render a news stream of short messages based on
The Problem I want to press a key when I have a line highlighted

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.