Why Visual studio 2017 is publishing entire solution? - c#

Installed VS2017 from scratch and moved existing vb.net, c# webform solutions to the new laptop.
First issue was related to "The target GatherAllFilesToPublish does not exist" error which I fixed by opening vbproj (or csproj on another project) and add this line:
<Target Name="GatherAllFilesToPublish">
</Target>
Now I was able to publish with no errors but the output in the destination folder is the entire solution including .aspx.vb or .aspx.cs files, .Global.asax.vb, .aspx.designer.vb files etc.
Checked the project Package/Publish Web settings and Items to deploy is set to "Only files needed to run this application".
Still the publishing copies the entire solution instead only the aspx, dll and only what is needed. Any idea what I am doing wrong ?

Edit csprojfile,in that file change vs version of your old project to vs 2015 in property group.save the file and rebuild .it will work properly.

Related

Visual Studio 2022 - file added in Windows Explorer not recognized by solution or Intellisense

My csproj file is defined with wildcard .cs file inclusion:
<ItemGroup>
<Include=".\**\*.cs" />
Is there a correct way to add files in the Windows Explorer, which would refresh the file list?
When I add .cs files in Windows Explorer, they aren't recognized by the solution explorer, even after I close and re-open Visual studio.
This worked in VS2015: closing and opening Visual studio made all new files part of the project, and Intellisense was working, code hilighting, go to definition, find all references, etc...
Not working in 2019 and 2022, but the workaround is to delete the .vs folder. Deleting it seems to reset some cached data, but I also lose a bunch of settings of the project.
(I don't know about VS2017 since I skipped that version).
I also tried to delete just the ".vs/ProjectName/v17/fileList.bin" file, but it doesn't help. I have to delete the ".suo" file as well.
I can add files in the Solution Explorer but that's a more cumbersome than just copy-pasting them between Windows Explorer windows that I have open. Also, it breaks the "include **.cs", since it changes the .csproj file and adds each file as a separate line like so
My workflow includes copy-pasting files from Explorer. Closing and reopening the IDE is annoying, but not such a hassle as deleting the .vs folder and losing all settings.
Also tried with alternative syntax ("CSFile" xml element instead of "Compile"):
<ItemGroup>
<CSFile Include="*.cs"/>
But there's no difference in functionality.
csproj file: https://pastebin.com/KEeFW4r7

Visual studio 2019 Removed project but still get reference in Temporary ASP.NET Files

I'm using Visual Studio 2019. I created a project and then decided that I didn't need it and removed it from my solution. The solution builds successfully. However, when I run the remaining projects, I get this error message in the YSOD:
The type or namespace name 'RemovedProject' could not be found. Source
File: c:\Users\%user%\AppData\Local\Temp\Temporary ASP.NET
Files\vs\63f72506\347f2602\App_Web_index.cshtml.ce0b5a11.bhx-cdpd.0.cs
If I delete the file, then it just appears back with the same reference but with a different extension before the 0 (ce0b5a11.bhx-cdpd in this example). VS is generating that file with that reference for some reason.
I've tried deleting the .vs folder in the solution folder, as well as the bin and obj folders of the remaining projects. I also deleted the temporary files in C:\Users\\%user%\AppData\Local\Microsoft\VisualStudio\16.0_08106da7\ComponentModelCache after shutting down VS, but that did not resolve the issue.
Any ideas on why VS keeps generating that file or how to resolve this issue?

VS2019 CS1566 when project has an licx file init

Recently upgraded to Visual Studio 2019. If there is a licenses.licx license file present in the project properties folder, the following error occurs at build time:
error CS1566: Error reading resource 'MyProgram.exe.licenses' --
'Could not find file
'C:\Sourcecodefolder\obj\x64\Debug\MyProgram.exe.licenses'.'
I tried setting "Copy to Output Directory" to "Copy always", on the .licx file. but that didn't help.
If I delete the license file, the app builds OK. As soon as I open a Windows form, Telerik create a new .licx file and adds it to the project. So every time I open a form in designer view, I have to go delete the .licx file before it will build. Thanks for any help.
I automate that by installing EmptyLicensesLicx NuGet package, which will make sure there's always an empty Licenses.licx file in your project, before it gets compiled (which is all you really need).

Web project migrated from VS2013 to VS2015 cannot be published

I had an Asp.Net MVC project, in VS 2013 update 4, and now I continue working on it in VS 2015. The Asp.Net version is not upgraded, i.e. I still use the stable asp.net 4 and MVC 5. The problem is: I cannot publish this project anymore. During the publish, it complains about xml files of every library I use, like EF, OWIN, ... both for Nuget libraries and normal .net framework libraries.
I tried adding these xml files from other sources and the publish proceeds further, but it raises another error like this:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(2991,5): Error : Copying file obj\Release\Package\PackageTmp\Content\bootstrap-rtl.min.css to obj\Release\Package\PackageTmp\obj\Release\Package\PackageTmp\Content\bootstrap-rtl.min.css failed. Could not find file 'obj\Release\Package\PackageTmp\Content\bootstrap-rtl.min.css'.
I removed this file from the project and the error still refers to this file. I searched the solution folder for this name, both in file names and file contents and I don't have it anywhere. It seems that Visual Studio has cached the publish procedure somewhere and does not update it when the project changes.
Any hints or solutions?
In our case the solution was to create a new clean project, then copy all source code files (C# code, javascript, css, razor templates, html, ..., but not for example, contents of bin and obj folders) from the old project into the new one, and then adding them to project (in solution explorer).
Don't waste too much time on solving this problem, dodge it.

How Do You Clear an ASP.NET app for compiling?

I have been building and rebuilding an ASP.NET program.
I made the horrible mistake, I think, of recently copying the published content back to the folder I was developing.
So now I have an unusual error when I build the code. It says That there is a duplicate definition in one file in a temporary directory with anohter file in a temporary directory.
Error 3
The type 'ChildEventHandler' exists in both
'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files...\b90cc7a4\28d266b\assembly\dl3\c4cf1ea3\b6e4b808_ef7cce01\App_Code.DLL'
and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files...\b90cc7a4\28d266b\App_Code.asx5jp5d.dll' C:\inetpub\wwwroot...\Resources\usercontrols....ascx.cs 11 18 C:......\
I removed project and file names, of course, but this is basically what the error says.
Since the error is with temporary files, what should I do?
I do not see a "clear" option in visual studio to clear out the files of a compile.
This problem I faced sometimes back while compiling. Go to this folder
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files and delete all the files and folder under it. When you build an application which is not hosted under IIS, temporary debug files and folder get created under this folder.
It may happen that you get an access denied error while deleting them. Close your Visual Studio solution and delete everything under this folder. It will resolve the compilation error.
For those using Visual Studio 2015 in Windows 8 or Windows 10, the solution is to remove all temp files from the following location:
%AppData%\Local\Temp\Temporary ASP.NET Files
and then rebuild your Solution.
In my case, the error is come from some cshtml files that are under project folder but not included in project. So if you search the error in entire solution, it couldn't be found. You can use show all files to show the not included files, and try to open them to find the possible files that cause the error.
If you haven't got the option of "Clean Solution" (maybe Express verions, or pre-2010 don't have this?) then, to fix this error, simply go to the /bin folder of your solution and delete all items, then Build again.
This will recompile all the DLL files.

Categories