Visual Studio web project publish not working - asp.net

I have a finished web project ready to publish. It works fine when I run it in Visual Studio. Then I go to publish it. Visual Studio claims the publication was successful, but when I go to the site on IIS it does not work. The published file system doesn't even have the Images folder, and the links to the Scripts and other folders don't work.
To describe what's happening, first I choose Build-->Publish site. I create a publish profile like so:
Then I publish it as a File System and pick the folder:
Then I publish it as Release:
Then I press Publish:
Here is the output of the publish website by Visual Studio:
------ Build started: Project: LangSite, Configuration: Release Any CPU ------
LangSite -> C:\Users\Administrator\documents\visual studio 2013\Projects\LangSite_151209\LangSite_151209\bin\LangSite_151209.dll
------ Publish started: Project: LangSite, Configuration: Release Any CPU ------
Connecting to C:\Users\Administrator\Documents\LangTestSite...
Transformed Web.config using C:\Users\Administrator\documents\visual studio 2013\Projects\LangSite_151209\LangSite_151209\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
Copying all files to temporary location below for package/publish:
obj\Release\Package\PackageTmp.
Publishing folder /...
Publishing folder Areas...
Publishing folder Areas/HelpPage...
Publishing folder Areas/HelpPage/Views...
Publishing folder Areas/HelpPage/Views/Help...
Publishing folder Areas/HelpPage/Views/Help/DisplayTemplates...
Publishing folder Areas/HelpPage/Views/Shared...
Publishing folder bin...
Publishing folder Content...
Publishing folder fonts...
Publishing folder Scripts...
Publishing folder Views...
Publishing folder Views/Home...
Publishing folder Views/Shared...
Site was published successfully file:///C:/Users/Administrator/Documents/LangTestSite
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
Here is the layout of the file folders in Visual Studio:
And here is the file structure of the published site. Notice, no Images folder:
When I try to go to the site, I get a page of broken links:
Clearly I am not using the publish web project correctly, but I don't see any different way to do it. What am I doing wrong?

Chances are that your images are in the file system, but they are not in your actual project.
You'll want to tell Visual Studio to 'show all files' its one of the icons in the top of the solution explorer. From there you can see the grayed out items show up under the images folder, and right click and "include in project".

Related

What to copy for a .Net Core console application publish?

I have an incredibly simple .NET core console application that I'd like to publish into a self contained executable. My application uses an the Microsoft.Extensions.Configuration.Json package so I can use an appsettings.json file.
From the command line, in the .csproj folder, I run
dotnet publish --self-contained true -r win-x64
. Inside my Debug folder, I see a netcoreapp2.1 folder and then the win-x64 folder. Inside that folder, I see the following:
publish -> folder
myapp.deps.json
myapp.dll
myapp.exe
myapp.pdb
myapp.runtimeconfig.dev.json
myapp.runtimeconfig.json
appsettings.json
hostfxr.dll
hostpolicy.dll
Am I supposed to copy just the files from this directory or do i have to copy the entire publish folder along with the files to my destination on a Windows Server? Or did I miss a switch to condense these items down further so movement from server to server is even simpler?
Copying just the files from the win-x64 directory was not enough. I needed to copy up the entire publish folder and run the application from that directory, otherwise error messages such as not being able to find a dependency would occur.

Sharing .netcore project between windows and linux Keeps adding files

I am working on a group project and we have decided to use netcore for the project. The project was originally created using VS.
When I pull the project and run it using VSCode, I have noticed two things:
I have to navigate to the src folder and run it from there.
Before pushing new changes to the master branch, .netcore on linux has made changes to obj folder and added .vscode folder.
how can I stop this from happening so we don't step over each others toes, and why does this happen?
Thanks.
You should not add the files under obj to source control. It contains artifacts that are regenerated on every build.
If you use git, here's a suggested list of files and folders to ignore:
[Oo]bj/
[Bb]in/
.vs/
*.xap
*.user
/TestResults
*.vspscc
*.vssscc
*.suo
*.cache
*.docstates
_ReSharper.*
*.csproj.user
*[Rr]e[Ss]harper.user
_ReSharper.*/
packages/*
artifacts/*
msbuild.log
PublishProfiles/
*.psess
*.vsp
*.pidb
*.userprefs
*DS_Store
*.ncrunchsolution
*.log
*.vspx
/.symbols
nuget.exe
build/
*net45.csproj
*k10.csproj
App_Data/
bower_components
node_modules
*.sln.ide
*.ng.ts
*.sln.ide
project.lock.json
.build/
.testpublish/
launchSettings.json

publish failed build successful vs2008

------ Build started: Project: CUOnlineManager, Configuration: Debug Any CPU ------
CUOnlineManager -> E:\Vault\CUOnlineManager3\CUOnlineManager\bin\CUOnlineManager.dll
------ Publish started: Project: CUOnlineManager, Configuration: Debug Any CPU ------
Connecting to E:\E\55...
Publishing folder /...
Publishing folder App_Data...
Publishing folder BusCards...
Publishing folder BusCards/Images...
Publishing folder Clearance...
Publishing folder Controls...
Publishing folder CoordinationOffice...
Publishing folder Coordinator...
Publishing folder culogin...
Publishing folder DarkReports...
Publishing folder DateSheet...
Publishing folder DirectorConsole...
Publishing folder DirectorConsole/COMSIS...
Publishing folder DirectorConsole/CUPortal...
Publishing folder DirectorConsole/FacultyFolder...
Publishing folder DirectorConsole/Library...
Publishing folder DirectorConsole/StudentFee...
Publishing folder Faculty...
Publishing folder Faculty/Portal...
Publishing folder FacultyManagement...
Publishing folder FeedBack...
Publishing folder FeedBack/CSS...
Publishing folder FeedBack/FacultyRepeaterReports...
Publishing folder FeedBack/images...
Publishing folder FeedBack/Reports...
Publishing folder FeedBack/Scripts...
Publishing folder HOD...
Publishing folder HOD/Attendance...
Publishing folder HOD/EmployeeAttendance...
Publishing folder HOD/FacultyFolder...
Publishing folder HOD/Offices...
Publishing folder HOD/Reports...
Publishing folder HOD/Students...
Publishing folder HR...
Publishing folder images...
Publishing folder Library...
Publishing folder obj...
Publishing folder obj/Debug...
Publishing folder obj/Debug/Refactor...
Publishing folder obj/Debug/TempPE...
Publishing folder obj/Release...
Unable to add 'obj/Release/CUOnlineManager.dll' to the Web site. Unable to add file 'obj\Release\CUOnlineManager.dll'. The system cannot find the file specified.
Unable to add 'obj/Release/CUOnlineManager.pdb' to the Web site. Unable to add file 'obj\Release\CUOnlineManager.pdb'. The system cannot find the file specified.
Publishing folder Officers...
Publishing folder resources...
Publishing folder resources/css...
Publishing folder resources/images...
Publishing folder resources/images/icons...
Publishing folder resources/img...
Publishing folder resources/jqueryUI...
Publishing folder resources/jqueryUI/base...
Publishing folder resources/jqueryUI/base/images...
Publishing folder resources/jqueryUI/redmond...
Publishing folder resources/jqueryUI/redmond/images...
Publishing folder resources/jqueryUI/themes...
Publishing folder resources/jqueryUI/themes/base...
Publishing folder resources/jqueryUI/themes/base/images...
Publishing folder resources/jqueryUI/themes/redmond...
Publishing folder resources/jqueryUI/themes/redmond/images...
Publishing folder resources/jqueryUI/ui...
Publishing folder resources/jqueryUI/ui/design...
Publishing folder resources/jqueryUI/ui/i18n...
Publishing folder resources/jqueryUI/ui/minified...
Publishing folder resources/scripts...
Publishing folder resources/timepicker...
Publishing folder resources/timepicker/include...
Publishing folder resources/timepicker/include/ui-1.10.0...
Publishing folder resources/timepicker/include/ui-1.10.0/ui-lightness...
Publishing folder resources/timepicker/include/ui-1.10.0/ui-lightness/images...
Publishing folder SMS...
Publishing folder StudentAffairs...
Publishing folder StudentManagement...
Publishing folder theme...
Publishing folder theme/resources...
Publishing folder theme/resources/css...
Publishing folder theme/resources/images...
Publishing folder theme/resources/images/icons...
Publishing folder theme/resources/scripts...
Publishing folder theme/resources/scripts/lib...
Publishing folder theme/resources/scripts/tests...
Publishing folder theme/resources/scripts/tests/functional...
Publishing folder theme/resources/scripts/tests/unit...
Publishing folder TimeTable...
Publishing folder bin...
Publishing folder bin/bin...
Publishing folder bin/obj...
Publishing folder bin/obj/Debug...
Publishing folder bin/_sgbak...
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
If you have multiple projects in your solution, try rebuilding each one separately 1st then build your main project and publish.
Sometime I would notice behaviour like this in 2008, ALSO make sure your building in debug mode for pdb files to be created.
separately, try upgrading the solution as soon as you can to VS2012/13

pubxml web publish tool Event Lifecycle

I am using the Web publishing tool from Visual Studio 2012 to publish to File System. I learned that I can open my *.pubxml in the Properties folder to do more advanced things.
What I want to do is run a command line application at the end of the publishing task.
I would usually do it in a Custom Target and execute it after one of the build in Events like this.
<Target Name="CustomAfterPublish" AfterTargets="GatherAllFilesToPublish">
</Target>
The problem is that GatherAllFilesToPublish is way to early because I want to execute it at the very last, after publishing was done.
Is there a list or does someone know the build in events and there order in which they are fired? Basically the Event Lifecycle of a FileSystem web publish.
Or how can I fire a Target manually at the very end?
I tried following without success:
<Target Name="Msg" AfterTargets="PipelineDeployPhase;MSDeployPublish;Package">
And also every each of them individually.
So what's the very last hook of the publishing lifecycle?
---> Edited
I added already tracing. The problem is that the files were copied to a temp path and after that all files are deleted. So copying to the destination will not work after "GatherAllFilesToPublish"See my trace from the command line window here...
1>------ Build started: Project: Dependency of a project: Release Any CPU ------
2>------ Build started: Project: Dependency of another project, Configuration: Release Any CPU ------
3>------ Build started: Project: Web, Configuration: Release Any CPU ------
4>------ Publish started: Project: Web, Configuration: Release Any CPU ------
4>Transformed Web.config using C:\...\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
4>Copying all files to temporary location below for package/publish:
4>obj\Release\Package\PackageTmp.
**<------------- Here is the place where my excutable is called ---------------------------------**
4>Deleting existing files...
4>Publishing folder /...
4>Publishing folder App_Browsers...
4>Publishing folder App_Themes...
4>Publishing folder bin...
4>Site was published successfully file:///C:/Test
4>
========== Build: 3 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
Thanks for any help.
As far as I can tell GatherAllFilesToPublish is the last event available. However, depending on your requirements you may still be able to use this event.
Instead of performing operations on files in the final publish location, you can target the intermediate files written to the location below (where ProjectDir is the folder of your project obviously)
/ProjectDir/obj/Release/Package/PackageTmp/
It seems that Visual Studio does a straight copy of all files in this directory. So, when hooking into GatherAllFilesToPublish you should be able to make any changes to the files in this directory and they will be reflected in the final publish location.
Related Information
If you'd like to verify that GatherAllFilesToPublish is truly the last event you can do this yourself by enabling Diagnostic build output.
Tools -> Options -> Projects and Solutions -> Build and Run -> MSBuild
project build output verbosity -> Diagnostic
Build the project and search for Done building target "GatherAllFilesToPublish", for me this was the last trigger before it started copying the files to the publish location.
I had the same problem. Your solution
Coping first to the temp directory and let web publish picking up the
coping for publishing
was helpful.
I just want to share for other people how it can be done:
<Target Name="CopyConfigForPublish" AfterTargets="CopyAllFilesToSingleFolderForPackage" Condition="exists('$(SolutionDir)Web.Common\bin\$(Configuration)\Log.config')">
<Copy SourceFiles="$(SolutionDir)Web.Common\bin\$(Configuration)\Log.config" DestinationFolder="$(WPPAllFilesInSingleFolder)" />
</Target>
I had a similar issue.
As far as i could check, "GatherAllFilesToPublish" is the last target you can deal with. You can use it doing an AfterTargets.
And use this >
$(MSBuildProjectDirectory)\obj\Release\Package\PackageTmp
To manipulate anything there.
What I did was creating an .bat file to do the dirty work.
You can find out which one is the variable that stores the relative part of the path (\obj\Release\Package\PackageTmp) and use it on more refined way.

Web Setup project not generating .msi file

I have a solution with a web setup project and a large website project in visual studio 2008.
When building the setup project it removes the setup.exe and the .msi file (which it is supposed to), the error occurs when it creates these files.
It creates the setup.exe file but not the .msi file, in its place is a .tmp
Let me know if more information is needed. I am thankful for the help.
Below is the output window and error.
------ Build started: Project: C:\...\GrandUnifiedWebSliceTheory\, Configuration: Debug Any CPU ------
Validating Web Site
Building directory '/GrandUnifiedWebSliceTheory/19002_DistrictManagement/'.
Building directory '/GrandUnifiedWebSliceTheory/19005_ManualAdjustment/'.
Building directory '/GrandUnifiedWebSliceTheory/19010_AllStatementListing/'.
Building directory '/GrandUnifiedWebSliceTheory/19050_MortgageExport/'.
Building directory '/GrandUnifiedWebSliceTheory/19060_StatementDataExport/'.
Building directory '/GrandUnifiedWebSliceTheory/24570_ParcelPermit/'.
Building directory '/GrandUnifiedWebSliceTheory/29571_OpenSpaceTimberRemoval/'.
Building directory '/GrandUnifiedWebSliceTheory/29572_DFLRemoval/'.
Building directory '/GrandUnifiedWebSliceTheory/29605_ExemptStatusChange/'.
Building directory '/GrandUnifiedWebSliceTheory/29606_DestroyedProperty/'.
Building directory '/GrandUnifiedWebSliceTheory/82005_GDoc_BuildingPermit/'.
Building directory '/GrandUnifiedWebSliceTheory/9520_QuickViewAA/19097_RelatedSta/'.
Building directory '/GrandUnifiedWebSliceTheory/9520_QuickViewAA/19098_TxRollCorrect/'.
Building directory '/GrandUnifiedWebSliceTheory/9520_QuickViewAA/24555_BuildingPermit/'.
Building directory '/GrandUnifiedWebSliceTheory/9520_QuickViewAA/25030_ParcelSaleHistory/'.
Building directory '/GrandUnifiedWebSliceTheory/9520_QuickViewAA/25099_QuickValueSummary/'.
Building directory '/GrandUnifiedWebSliceTheory/9520_QuickViewAA/9702_GISImaging/'.
Building directory '/GrandUnifiedWebSliceTheory/9521_QuickViewTR/19097_RelatedSta/'.
Building directory '/GrandUnifiedWebSliceTheory/9521_QuickViewTR/19098_TxRollCorrect/'.
Building directory '/GrandUnifiedWebSliceTheory/9521_QuickViewTR/19099_Ownership/'.
Building directory '/GrandUnifiedWebSliceTheory/9521_QuickViewTR/25030_ParcelSaleHistory/'.
Building directory '/GrandUnifiedWebSliceTheory/9521_QuickViewTR/25099_QuickValueSummary/'.
Building directory '/GrandUnifiedWebSliceTheory/9521_QuickViewTR/95020_StatementHeaders/'.
Building directory '/GrandUnifiedWebSliceTheory/9521_QuickViewTR/JS/'.
Building directory '/GrandUnifiedWebSliceTheory/96010_OwnerSummary/'.
Building directory '/GrandUnifiedWebSliceTheory/JS/'.
Building directory '/GrandUnifiedWebSliceTheory/'.
Validation Complete
------ Starting pre-build validation for project 'GuwtSetup' ------
------ Pre-build validation for project 'GuwtSetup' completed ------
------ Build started: Project: GuwtSetup, Configuration: Release ------
Building file 'C:\Documents and Settings\Desktop\svn\GrandUnifiedWebSliceTheory\GuwtSetup\Release\GuwtSetup.msi'...
**ERROR: Could not find file 'C:\Documents and Settings\Desktop\svn\GrandUnifiedWebSliceTheory\GuwtSetup\Release\GuwtSetup.msi' 'The system cannot find the file specified.'**
========== Build: 1 succeeded or up-to-date, 1 failed, 0 skipped ==========
Figured it out thank you for all the views. The answer was, somehow in the project properties the web setup project release checkbox was marked. Unchecking this box allowed somehow fixed the problem
Watch the output panel, it will probably indicate what the error is.
Figured it out thank you for all the views. The answer was, somehow in the project properties the web setup project release checkbox was marked. Unchecking this box allowed somehow fixed the problem

Resources