allowDefinition='MachineToApplication' msbuild error

后端 未结 12 1514
后悔当初
后悔当初 2020-12-24 10:51

We have a ASP.NET MVC with 4-5 different build configurations. Whenever we change the build configuration, we need to delete the obj folder for the web project, since we get

相关标签:
12条回答
  • 2020-12-24 11:23

    I don't know that there is an "official" fix as it just seemed to start on multiple projects of mine for no reason that I can find in Visual Studio Premium 2012 (never happened in previous versions of VS).

    As a work around to automate the deletion of the obj directory as others have said, similar to an answer by user Casual in this post VisualStudio: How to save the obj folder somewhere else, where unfortunately just moving the location of the obj folder didn't always seem to work.

    Instead I added a few commands under Build Events in the Pre-build event command line:

    rd "$(ProjectDir)obj" /S /Q
    md "$(ProjectDir)obj"
    md "$(ProjectDir)obj\Debug"
    md "$(ProjectDir)obj\Release"
    

    You can change/add/remove subfolders to match your custom build configurations using the line where buildConfigName matches the name of the build configuration you are using:

    md "$(ProjectDir)obj\buildConfigName"
    

    Hope this helps!

    0 讨论(0)
  • 2020-12-24 11:24

    tip 1: clean & then rebuild.

    tip 2: just close VS and open again.

    tip 3: the downloaded project may be inside another sub folder... open the folder which has you .net files.

    c:/demo1/demo/ (all files)

    You should have to open demo from vs... not demo1.

    0 讨论(0)
  • 2020-12-24 11:27

    I have a somewhat a similar problem, i had the main config as Copy Always so it copied the config to the bin directory. When i republished the main project, i got the MachineToApplication error. So my solution was to just change the config to Do Not Copy and remove the extra configuration in the bin folder.

    0 讨论(0)
  • 2020-12-24 11:34

    I had the same error but with a deployed page.. Then realized my webserver's clock was set back to 2010 for some reason. set it to the correct date fix my problem

    0 讨论(0)
  • 2020-12-24 11:34

    Clean your project Remove the /obj folder (probably using publish and deploy? - there is a bug in it)

    0 讨论(0)
  • 2020-12-24 11:38

    Cleaning the solution (Right click Solution in VS, clean), worked for me.

    0 讨论(0)
提交回复
热议问题