publish has encountered an error Object reference not set to an instance of an object A diagnostic log has been written to following location
Microsoft Net Framework

Problem:

when we publish website using Visual Studio, we are getting following erros.

publish has encountered an error Object reference not set to an instance of an object A diagnostic log has been written to following location

Change the target location in publish profile, this error occurs when same folder used for more than one project.

Error

Severity    Code    Description    Project    Path    File    Line    Suppression State    Suppression State
Error        Copying file obj\Release\Package\PackageTmp\Scripts\bootstrap.min.js to obj\Release\Package\PackageTmp\obj\Release\Package\PackageTmp\Scripts\bootstrap.min.js failed. Could not find a part of the path 'obj\Release\Package\PackageTmp\Scripts\bootstrap.min.js'.    InnerException.WebUI            0        


Solution


Open your .csproj file with a text editor (Notepad, Notepad++) Visual Studio will open it as a project.

Press Ctrl + F and search for the file of the problem. In my case the file was "Hello.txt" without commas.

Under the <ItemGroup> it resided:

<ItemGroup>
<Content Include="App_Data\NuGetBackup\yourfilename.txt" />
<Content Include="Content\admin\yourAdmin.css">
    <DependentUpon>Admin.scss</DependentUpon>
</Content>

I deleted the <Content Include="App_Data\NuGetBackup\yourfilename.txt" /> line, and voila! Visual Studio allowed me to Preview before publishing!

It will end like this:

<ItemGroup>
<Content Include="Content\admin\Admin.css">
    <DependentUpon>Admin.scss</DependentUpon>
</Content>


*************************


Se Default path of published=> bin\Release\Publish

Delete all published profile

Solutions

    -Files are missing, just include files. those are giving error

Solution 0

Change the target location in publish profile, this error occurs when same folder used for more than one project.

Solution 1

- Remove all warning from the project

- Delete temp files in AppData/Local/Temp


- File Publish option
    - Check all text boxes like Delete All existing files
    - Precompile during...
    - Exclude files from...


Solution 2

here are few more instructions

- Run Visual Studio as Administrator
- Clean the Solution or project
- Delete all files into obj Directory
- Review if any files need to include in the project
- Build Solution again.

Share This with your friend by choosing any social account


Upcoming Articles
You may also read following recent Post
Copyright Future Minutes © 2015- 2024 All Rights Reserved.   Terms of Service  |   Privacy Policy |  Contact US|  Pages|  Whats new?
Update on: Dec 20 2023 05:10 PM