I’m trying to publish my project which has references to other projects in my solution.
Whenever I build the solution regularly it builds just fine without any errors.
However, whenever I attempt to publish the project I get the message “Build failed”.
When I check the output log I see the following 3 errors:
C:UsersMyUsernameDropboxProjectsSEOQualityLinkBuilderWebRealestateJobsMigrationsRealestateJobsConfiguration.cs(10,101,10,124):
error CS0234: The type or namespace name ‘RealestateJobsDbContext’
does not exist in the namespace ‘RealestateScraper’ (are you missing
an assembly reference?)C:UsersMyUsernameDropboxProjectsSEOQualityLinkBuilderWebRealestateJobsMigrationsRealestateJobsConfiguration.cs(18,56,18,79):
error CS0234: The type or namespace name ‘RealestateJobsDbContext’
does not exist in the namespace ‘RealestateScraper’ (are you missing
an assembly reference?)C:UsersMyUsernameDropboxProjectsSEOQualityLinkBuilderWebViewModelsJobsVm.cs(364,51,364,69):
error CS0246: The type or namespace name ‘ClosedRealestateId’ could
not be found (are you missing a using directive or an assembly
reference?)
However, I have referenced the project “RealestateScraper” and the class RealestateJobsDbContext&ClosedRealestateId exists in the “RealestateScraper” project root namespace which HAS been marked as using in the locations where the output marked the errors.
(like I previously stated, the project builds fine too when not publishing).
What could be the issue here?
I have cleaned&rebuilt but that doesn’t seem to change anything.
Note: I’m not showing the code with the errors since it seems to serve no purpose as I am referencing the assemblies in the files correctly (using RealestateScraper;)
6
Answers
Apparently in the RealestateScraper project I was referencing another project .dll at a location where it no longer existed. I updated the reference location and it fixed it.
I was experiencing this as well- build only failed during publish. Turns out I was using the wrong password for the azure publish and for some reason I cannot explain it would show that the build failed and include some build errors. After correcting the password this was resolved.
In my case, I could not identify the error itself. I just changed the publish property “pre-compile”. I UNchecked it and then I was able to publish my website
I had some compiler if-then statements in a class. These worked okay when I did a local build, but when publishing they were not interpreted and caused build errors. I refactored my code to remove the compiler directives and it now publishes.
Example:
Changed to:
unfortunately I have the same unresolved problem solution -prog a -prog b completes both the prog and the solution but when I go to publish it gives me error c0246 on using of the project b called in the project a
Help
I tried all of these solutions, and they might have contributed, but I was still getting the error.
I was tipped off by a warning. I had to make this file not read-only within the project, then it worked.
objReleasenetcoreapp3.0PubTmpOutweb.config