Build succeeds, but publish fails
Asked Answered
B

23

44

Up until two days ago, I was able to use Visual Studio 2010's "Publish Web" option by right clicking on my project and clicking the publish button on the context menu. Now when I try to do the same thing, I get the following output:

------ Build started: Project: ELMS, Configuration: Debug Any CPU ------
Build started 8/1/2011 3:08:03 PM.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are
up-to-date with respect to the input files.
_CopyOutOfDateSourceItemsToOutputDirectoryAlways:
Copying file from "C:\SVN\TrakNet\trunk\MTS\lib\Newtonsoft.Json.Net35.dll" to 
  "bin\lib\Newtonsoft.Json.Net35.dll".
CopyFilesToOutputDirectory:
  LMS -> C:\SVN\TrakNet\trunk\MTS\bin\LMS.dll

Build succeeded.

Time Elapsed 00:00:00.04
------ Publish started: Project: LMS, Configuration: Debug Any CPU ------
Object reference not set to an instance of an object.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

This is while attempting to publish to localhost (for debugging purposes)

Here are the settings of the publish profile that I'm using:

Publish Method: Web Deploy
Service URL: localhost
Site/application: default web site/ELMS
[x] Mark as IIS application on destination
[x] Leave extra files on destination (do not delete)

I have already attempted:

- Cleaning/rebuilding the project
- Deleting the bin folder of the project
- Running reg_iis.exe -i
- Reinstalling VS2010

but nothing I've changed has fixed the error.

Any insight into what might be causing the issue would be greatly appreciated :)

EDIT:

The problem actually resolved itself as of my last reboot. I must have rebooted 6-7 times since the problem first manifested itself, but this time no Object Reference message. Here's the log from the build/publish now:

------ Build started: Project: LMS, Configuration: Debug Any CPU ------
Build started 8/3/2011 9:10:12 AM.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
_CopyOutOfDateSourceItemsToOutputDirectoryAlways:
  Copying file from "C:\SVN\TrakNet\trunk\MTS\lib\Newtonsoft.Json.Net35.dll" to "bin\lib\Newtonsoft.Json.Net35.dll".
CopyFilesToOutputDirectory:
  LMS -> C:\SVN\TrakNet\trunk\MTS\bin\LMS.dll

Build succeeded.

Time Elapsed 00:00:00.04
------ Publish started: Project: LMS, Configuration: Debug Any CPU ------
Gather all files from Project items @(IntermediateAssembly). Adding:
bin\LMS.dll to bin\LMS.dll
bin\LMS.pdb to bin\LMS.pdb
Gather all files from Project items @(Content). Adding:
Global.asax;lib\Newtonsoft.Json.Net35.dll;MtsSchemas\MtsSchema.xml;Web.config
Gather all files from Project output (IntermediateSatelliteAssembliesWithTargetPath).
Adding:
Gather all files from Project items
@(ReferenceCopyLocalPaths,ReferenceComWrappersToCopyLocal,ResolvedIsolatedComModules,_DeploymentLooseManifestFile,NativeReferenceFile).
Gather all files from Project items @(AllExtraReferenceFiles). Adding:
Gather all files from Project items
@(_SourceItemsToCopyToOutputDirectoryAlways,_SourceItemsToCopyToOutputDirectory). Adding:
bin\lib\Newtonsoft.Json.Net35.dll
Gather all files from Project items @(_binDeployableAssemblies). Adding:
Publish Pipeline Collect Files Phase
Found The following for Config tranformation:
Web.config
Creating directory "C:\SVN\TrakNet\trunk\MTS\obj\Debug\TransformWebConfig\transformed\".
Publish Pipeline Transform Phase
Creating directory "C:\SVN\TrakNet\trunk\MTS\obj\Debug\CSAutoParameterize\transformed\".
Copying Web.config to obj\Debug\CSAutoParameterize\original\Web.config.
Transforming Source File: C:\SVN\TrakNet\trunk\MTS\Web.config
  Applying Transform File: <?xml version="1.0"?>
        <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
          <connectionStrings>
            <add
              connectionString="{% token='$(ReplacableToken_#(parameter)_#(tokennumber))' xpathlocator='name' parameter='$(name)-Web.config Connection String' description='$(name) Connection String used in web.config by the application to access the database.' defaultValue='$(connectionString)' tags='SqlConnectionString' %}"
              xdt:Transform="SetTokenizedAttributes(connectionString)" xdt:SupressWarnings="True" />
          </connectionStrings>
        </configuration>
      Output File: obj\Debug\CSAutoParameterize\transformed\Web.config
    Transformation succeeded
Auto ConnectionString Transformed Web.config into obj\Debug\CSAutoParameterize\transformed\Web.config.
Creating directory "obj\Debug\Package\PackageTmp".
Copying all files to temporary location below for package/publish:
obj\Debug\Package\PackageTmp.
Copying bin\LMS.dll to obj\Debug\Package\PackageTmp\bin\LMS.dll.
Copying bin\LMS.pdb to obj\Debug\Package\PackageTmp\bin\LMS.pdb.
Copying Global.asax to obj\Debug\Package\PackageTmp\Global.asax.
Copying lib\Newtonsoft.Json.Net35.dll to obj\Debug\Package\PackageTmp\lib\Newtonsoft.Json.Net35.dll.
Copying MtsSchemas\MtsSchema.xml to obj\Debug\Package\PackageTmp\MtsSchemas\MtsSchema.xml.
Copying C:\SVN\TrakNet\trunk\MTS\lib\Newtonsoft.Json.Net35.dll to obj\Debug\Package\PackageTmp\bin\lib\Newtonsoft.Json.Net35.dll.
Copying obj\Debug\CSAutoParameterize\transformed\Web.config to obj\Debug\Package\PackageTmp\Web.config.
Publish Pipeline Deploy phase Pre-Deploy CopyAllFilesToOneFolder Stage
Generate source manifest file for Web Deploy package/publish ...
Creating directory "obj\Debug\Database".
Starting Web deployment task from source:manifest(C:\SVN\TrakNet\trunk\MTS\obj\Debug\Package\LMS.SourceManifest.xml) to Destination:auto().
Updating filePath (default web site/LMS\bin\ELMS.dll).
Updating filePath (default web site/LMS\bin\ELMS.pdb).
Updating filePath (default web site/LMS\bin\lib\Newtonsoft.Json.Net35.dll).
Updating filePath (default web site/LMS\lib\Newtonsoft.Json.Net35.dll).
Updating filePath (default web site/LMS\Web.config).
Updating setAcl (default web site/LMS).
Updating setAcl (default web site/LMS).
Successfully executed Web deployment task.
Publish is successfully deployed.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

Like I said: No idea what changed. I had been manually moving the DLLs into the website's virtual directory, then just for kicks I tried publishing this morning, and everything worked out fine.

Bicameral answered 1/8, 2011 at 19:26 Comment(3)
Could you set the "MSBuild project build log file verbosity" to Detailed or Diagnostic (in VS/Tools/Options/Projects and Solutions/Build and Run) and post a more detailed log output, please?Peters
are you using any SVN plugin like ankhsvn?Meek
I'd recommend putting something about your "Object reference not set to an instance of an object" error in the title of this thread. Otherwise could be assumed to be (though I don't think it is) a duplicate of: https://mcmap.net/q/375262/-project-builds-but-can-39-t-publishCulliton
E
40

In my experience this can happen when files are added/removed from different branches of your source control and an imperfect merge causes the project file structure and the actual file structure to diverge.

This could be one of several options:

  • A file was deleted but the project still references it. Will fail to compile, will fail to publish.
  • A file was added but is not referenced by the project. May compile, depends whether the class/methods are referenced elsewhere in the project/solution. If compiles, will publish.
  • A file was added, but the project merge caused it to appear more than once in the project listing. Will compile, will fail to publish.

The solution is to look at the source control logs and trying to identify the bad merge to the project file for the above issues, then fixing the project file accordingly.

Enounce answered 16/11, 2011 at 18:14 Comment(3)
That could definitely have been the issue. I will check back through the source control logs and try to determine if this is the case. Edit: On review of the project file, I don't see any duplicated file names.Bicameral
I had a similar issue and nothing helped....except I was able to successfully deploy from another PC.Ogata
This solved my problem. I reverted to the first commit I could find that would publish, then diffed against the next commit. The only file I had to change was my csproj. Once it was cleaned up, publish to azure worked like a charm.Confess
B
18

Me also faced same issue, I just removed yellow marked file from visual studio project solution & it worked fine for me.

Brotherly answered 29/4, 2016 at 7:15 Comment(3)
Thanks, I excluded the bin folder from the project and the publish succeeded.Lament
I included yellow marked files (missing files to the .csproj) to the project and the publish succeeded.Barramunda
That is exactly what I had , after removing this file it worked successfullySalmon
C
15

Exclude the bin (and/or) obj folder from project and publish. This worked for me

Compilation answered 9/11, 2015 at 10:3 Comment(1)
In my case it was a bin folder included to the solution.Hygrometric
K
4

I had this issue recently publishing to Azure. I ended up deleting all the files in the bin folder( deleted all files WITHIN visual studio solution explorer under bin folder, but leave the bin folder itself empty) , and rebuilding the project. This seemed to make visual studio happy and azure publish worked. hope this helps

Kierkegaardian answered 16/2, 2015 at 17:56 Comment(0)
B
4

I removed bin & obj folder and also the content of the inetpub/wwwroot/myapp and problem solve

Bilbrey answered 16/11, 2016 at 17:37 Comment(0)
V
3

This worked for me: Manually delete the obj folder, rebuild, then publish. Somehow some permission in the obj folder got stuck, and deleting/recreating the folder cleared the error.

Valedictory answered 13/1, 2016 at 13:42 Comment(0)
I
3

nothings work for me. deleting obj and bin file-clean-changing webservice name-shorten webservice name.

But at all,

+Expand your Reference.svcmap from visual studio.

+Update reference.

+And delete yellow warning datasources.

works for me

Isaiah answered 2/6, 2017 at 7:18 Comment(0)
B
2

I recently faced the same issue. And I actually traced it by searching the file which was missing.

Reason for the error : In visual studio I had included the file and later on deleted it from file system.(but not from visual studio). VS had still had the reference to that file. So once I deleted the reference from VS I was able to publish successfully !

Brownout answered 5/2, 2017 at 12:1 Comment(0)
K
1

The cause of it is the transfer your project from different environment. To solve it, delete "obj" folder from your project directory as well as from solution explorer by right click on "obj" folder.

After that build your project and publish it. It will work normally.

Kreit answered 10/6, 2015 at 8:18 Comment(0)
J
1

open projectname.csproj file in notepad and remove obj\debug\project name.csprojResolveAsseblyReference.cache line

Justis answered 28/6, 2016 at 11:23 Comment(0)
C
1

I had to delete the publish profile, commit, and then recreate the publish profile from scratch.

Contractor answered 15/11, 2018 at 19:57 Comment(0)
T
0

I ran into a similar problem when I manually copied a folder into a project (in my case ckeditor). It built fine and ran locally with no issues. However, when publishing the folder was ignored. It turns out I had to create the empty folder 1st and then copy in the folder contents. Visual Studio needs to know the item was created it appears, because after that it was recognized upon publishing.

Tadd answered 7/2, 2014 at 14:38 Comment(1)
Could probably also right-click, select Add -> Existing ItemTincture
S
0

This issue may come because of move project from one solution to another solution or moving to another source control.

Simple way to resolve this issue:

  1. Take the current project backup and remove you current project from solution.

  2. Add new project to your solution and include your files from backup and rebuild your project and done.

Swedish answered 19/4, 2015 at 7:58 Comment(0)
H
0

I resolved this by removing the file "packages.config" from my Project, which was flagged as missing. After that, Publish worked just fine.

Hesitancy answered 19/10, 2015 at 22:7 Comment(0)
K
0

I had to manually copy and paste the missing files VS was asking for into the BIN folder. .pbd, .xml Sometimes they don't copy over.

Katsuyama answered 2/11, 2015 at 15:41 Comment(0)
T
0

Just rename Packages folder of Nugets. Visual Studio would automatically get required packages and build would get successful and Publish would work too.

Talon answered 2/9, 2016 at 9:17 Comment(0)
L
0

In case this helps anyone, for my MVC project in VS 2015 it was this file: File System.pubxml.user In the publish profile directory, including it caused compilation errors but deleting it enabled it to publish!

Lauderdale answered 12/10, 2018 at 15:7 Comment(0)
M
0

I deleted all the existing publish profiles in visual studio -> solution explorer -> My Project Node -> Properties -> Publish Profiles The same can be done by right clicking Project in solution explorer -> Publish -> Profile tab -> Manage Profiles -> Remove all profiles Now download the relevant profile from Azure or choose from your directory if it's already save on your machine and choose it. Then clean and rebuild the project. Make sure you've chosen the project is built in Release mode and you've also chosen "Release" Publish -> Settings -> Configuration Now Publish, it worked for me.

Mcelhaney answered 16/11, 2018 at 11:25 Comment(0)
S
0

i have also faced this issue while i was publishing my site, in my case reference was added but in bin folder it was not there so please install again which reference is missing on output.i hope it helps

Sorilda answered 27/3, 2019 at 10:36 Comment(0)
K
0

In my case it was delted file from Projects folder. It was added to project but it was not in source folder. I found that it shown with exclamation mark in visual studio:

enter image description here

when i excluded file form project publishing started to work

Keil answered 16/7, 2020 at 10:32 Comment(0)
B
0

I had a problem in vs2017 ,I just exclude bin and obj folder from projectn and publish project. it's work.

Benedetta answered 25/10, 2020 at 9:31 Comment(0)
T
0

I would like to add that in my case, if you're using Visual Studio 2015 and you have installed Microsoft.Net.Compilers NuGet package in any of your projects, make sure this package version is not greater than 2.4.

The reason why this mix is bad is because VS 2015 uses MSBuild v14 and the package requires MSBuild v15 or greater if version > 2.4.

Tamarra answered 28/12, 2021 at 17:36 Comment(0)
B
0

In my case project builds but does not publish. The reason for that referenced solution files exists in bin/release folder but they are old and do not refreshed.As a solution, in the Solution/Properties/Configuration Properties/Configuration section choose Configuration as Release and uncheck the checkbox under build column. Click Ok, restart VS. Open same settings menu and now check build checkbox. Problem solved.enter image description here

Babble answered 1/11, 2023 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.