First you need the project to build successfully.
Right-click the project name and select Publish
The Publish Options screen pops up,
Here we choose the Publish method as "file system"
Select "Target Location".
Select "Delete all existing files before publishing"
Click "Publish" to publish the program files at the target location.
Here the file, without CS file, only the foreground file, DLL and other files, to avoid post-release source code leaks.
However, sometimes we add some template files to the project, but after the release, we do not copy the files to the past, in this case, we need special handling of these file attributes
Right-click the file, and in the file properties, set the Build Action field to "content"
At this point, release ok!
VS2010 Publishing Web application in detail (resolving issues with publishing missing non-code files)