Visual Studio 2019: "delete existing files" option in publish profile disappeared - visual-studio

I've just updated my copy of Visual Studio to version 16.10, and something weird happened: when publishing a project, the "delete existing files" option is not editable anymore. You can see it but when opening the edit dialog there is no checkbox to edit it.
Here's a screenshot for clarification:
Is this a bug, or is it intended?
Is there an alternative way to set that option, or is it just not supported anymore?

I initially tried adding <DeleteExistingFiles>true</DeleteExistingFiles> to the pubxml file (under the Properties folder in VS). Unfortunately, this only update the Publish dialog but had no apparent effect on the publishing process.
For my workaround, I opted to add this to build event: del /S /Q $(TargetDir)publish. It clears out my publish directory on each build - you'll have to alter "$(TargetDir)publish" to fit your needs. The workaround is slight overkill, but arguably a better choice since there is less chance of the published files being picked up after a recent change/build.

I've just updated Visual Studio to version 16.11 and it seems they fixed it, the option is back in the settings menu:

Open .pubxml file in a text editor (mine was in Properties\PublishProfiles) and update/add the key DeleteExistingFiles to True.

I think regarding #Phil's answer, the 2 actions are doing different things.
1. DeleteExistingFiles
This will delete existing files on the web server when you actually deploy. I don't see any documentation about this setting from Microsoft which is frustrating. This same feature is available when you publish your application to a Web Deploy Package and use the Import feature in IIS to import the application. You will get a prompt like this:
This is the same as DeleteExistingFiles in a publish profile.
2. Publish directory
Deleting the publish directory is a different thing. The publish directory is a working directory of the msbuild /t:Publish or msbuild /t:Package commands. Basically what is in the publish directory is what ends up in the ZIP file used for a web deploy package or a publish profile. You can get issues during publish process with incorrect files in the publish directory. For example, https://github.com/scottksmith95/LINQKit/issues/157.
Unfortunately there is no way to delete or clean the publish directory with the existing msbuild or dotnet cli commands:
https://github.com/dotnet/sdk/issues/5972.
Fun times. So #Phil's del command is what we are left with.

Related

Visual Studio 2013 Website Publish Not Copying .pdb files

I have checked the answer for VS 2012, it did not work. I do not precompile, I have "Debug Info" set to "full", "Items to deploy" set to "Only files needed to run this application" and "Exclude generated debug symbols" not marked.
I have tested with "All files in this project", and I have tried to edit the pubxml file. Besides not working I cannot find the file schema documentation.
Please help.
After a lot of tests, I noticed that "Exclude generated debug symbols" flickered as marked during the publish processing. My error was that I was editing the Active configuration -- which was Debug -- and not the Release configuration used in my publish process.
Please verify the Configuration combo on the project properties page, this was bizarre until I noticed that.
There´s an option in the Advanced Precompile Settings dialog (which is off by default); you find this dialog via the Settings tab of the Publish Web wizard... watch out for the (unoticable) Configure-link in the File Publish Options-drop-down...
I've searched for this and tried every trick posted and nothing worked.
The only thing that worked for me was to take a copy of the bin folder and then delete all files from the bin folder and rebuild.
When publishing I got a new error of a missing .dll which I had in the backup folder. When I copied it to the bin folder I was finally able to publish.

SharePoint development in visual studio without having to deploy/debug on every code changes

I'm using VS2010 connected to a local SP2010 installation, I edit the code in VS2010 (i.e. of a WebPart) and then in order to see the result on a browser I deploy the solution.
This is very annoying since it is a big project and it takes a couple of mins to deploy the solution.
I was wondering if it is possible to have the "edit -> save -> F5" approach even for SharePoint.
Thanks!
I'm gonna to integrate here the answer i get from the kind ppl and what i've actually done to solve/mitigate my slowness problem:
Installed CKSDev Visual Studio plugin from here: http://cksdev.codeplex.com/
On the SharePoint project properties tab set to 'True' the property 'Auto copy to SharePoint root', with that on each time you do save a 'visual' (ascx, aspx, js, css, ..) source file, it will be automatically copied over the SP hive without having to manually push it using the Quick Depl. option
On SharePoint project properties page (right-click, properties), add the following post build event command line:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe" /i "$(TargetPath)"
iisreset
The previous commands will:
Install the project dlls into the GAC
Restart IIS in order to catch the new dlls
Now each time you do save a change in the visual or build the code it will automatically pushed to the SP installation.
For newer source files i still need to normally deploy the project.
You can do that by copying the modified file to the corresponding folder inside SharePoint Hive[14] (Or you can edit it there directly), and recycle the application pool.
Note that it this solution is only applicable to web parts, pages and xml files and it cannot be done for code files.
If you have modified your code files you have to recompile them and copy the dlls to GAC[%systemroot%\assembly] or BIN[14\bin] folder depending on your settings.
Download CKS: Development Tools Edition (aka CKSDev) from here and install into VS 2010. You will see new context menu "Quick Deploy" in solution manager which will speed up requested tasks: deploy to GAC/BIN, Recycle App Pool and more (shortcuts are accessible!). Very handy tool.
Use CKSDev, and separate your solution into smaller solutions so you can work on a subset of your projects, I would be very surprised if your webpart is dependent on every project in your master solution. If you are developing on a virtual machine without internet access also ensure that you are not waiting for timeout on your certification checks everytime you recycle the apppool (happens when you deploy). Read here for how to: http://joelblogs.co.uk/2011/09/20/certificate-revocation-list-check-and-sharepoint-2010-without-an-internet-connection/
I am going though below step during debug code.
1) if you are changes only code assembly than Build Your Project after changes code.
2) Open Assembly folder(run > assembly) and drag and drop your project's dll(will be found it out from Your Project Directory\bin\Debug).
3) open IIS (run > inetmgr) and goto Application Pools and find it out your sharepoint we-app's Pool. after selecting Application Pool (Recycle) it.
4) now come back on VS SharePoint Project.Debug > Attach to Process > w3wp.exe.
should be hit your break point.
that's it.

How to temporarily exclude files from being built

My project files are controlled by Perforce and I have installed the SCC plugin so that I can work directly with Perforce inside Visual Studio 2010.
Here is the problem I have:
Inside the project, there are several files that I don't want to take into consideration while I build the project. If I use the context menu "Exclude from Project", I saw the following warning message:
Checked out items cannot be deleted by your source control provider.
If you continue with the change, you may need to manually delete
xxx.‌h in the source control database.
Is there a workaround that I can use?
Thank you
If you simply do not want them to compile, select the code file and look at the Properties window. Set Build Action to content or some other non-compile setting.

VS2010 - publish website, empty folders are ignored

In visual studio 2010, when publishing a website, it seems that empty folders are not being published.
I am quite sure that this behavior were introduced in vs2010. I cant find it documented anywhere, not sure if I should call it a feature or a bug... Anyway, is it possible to revert to the old behavior as I wish to keep my folder structure on the production server.
This is actually a limitation of vs2010 as reported on the Microsoft connect site
http://vishaljoshi.blogspot.com/2007/11/wdp-does-not-publish-empty-folders.html
http://connect.microsoft.com/VisualStudio/feedback/details/546356/publish-deploy-does-not-deploy-empty-folders
There was a bug report to Microsoft about this and they said that they would not fix it.
http://connect.microsoft.com/VisualStudio/feedback/details/546356/publish-deploy-does-not-deploy-empty-folders
Too bad. Because it used to work in Visual Studio 2008.
Add a dummy file like dummy.txt to the directory and then the directory will be created.
Note that it is not necessary to actually deploy the dummy file. It only needs to exist as part of the project in the build environment.
The Empty folder doesn't have any memory value so if you want to add your folder's into your published folder then simply add any item(e.g. text File) into it and set the "Copy to output directory" = Copy always or Copy if Newer this will resolve you problem

Problem after publishing web application from VS 2010

Whenever I publish my MVC web application in VS 2010 via the One-click publish feature (I'm not doing any web.config transforms or anything fancy - yet!). The next time I come to build the app I get the following error:
It is an error to use a section registered as allowDefinition='MachineToApplication'
beyond application level. This error can be caused by a virtual directory not being
configured as an application in IIS. in ...MyWebApp\obj\release\package\packagetmp
\web.config
A new copy of the web.config file is indeed created by VS2010 below the ...MyWebApp\obj\ folder so I deleted the whole obj folder and I was then able to build again.
But I shouldn't have to do that each time I publish - I must have something configured incorrectly - can anyone help please.
Thanks.
This is unfortunately a known issue with Publishing a web application to the file system. This still affects the release version (RTM) of Visual Studio 2010. It's not limited to the Beta or RC versions.
This problem "bit" me also, and I too was having to manually delete the Debug and Release folders inside the obj folder within my web site solution folder.
The real answer for an automated "workaround" can be found in this answer to the other Stack Overflow question:
Why do I randomly get a “error to use section registered as allowDefinition='MachineToApplication'” when building an MVC project?
In a nutshell, you need to delete the web.config files from either the Debug or Release folders (or both!), and that's achieved with a pre-build command (configured in the Build Events tab of the Project Properties page of your solution):
del "$(ProjectDir)\obj\Debug\Package\PackageTmp\web.config"
del "$(ProjectDir)\obj\Release\Package\PackageTmp\web.config"
Personally, I delete the entire obj folder since all those files are re-created with each build anyway.
I have just found a work around for this that has worked for me, open the .csproj for your web project and change the node under the Project\PropertyGroup node to this:
from this:
<MvcBuildViews>true</MvcBuildViews>
to this:
<MvcBuildViews>false</MvcBuildViews>
This has worked for me, hopefully it will work for you also.

Resources