Disable Publishing in MSBuild - c#

I have an application that I wrote in C# and build in VisualStudio. One day I was exploring the 'publish' tab in the project properties section just to see what it did. Now everytime I build my application, I get a whole bunch of files related to ClickOnce installers (*.application, *.deploy, etc.) that I don't really want anymore. How do I disable or otherwise stop these items from appearing when I build my project??

I solved the problem by unchecking 'Sign ClickOnce Manifests' in the 'Signing' tab as well as 'Enable ClickOnce security settings' in the 'Security' tab.

For WinForms Windows Application
Go to: Project > Properties > Security
Then uncheck 'Enable ClickOnce security settings'

2 ways to do it,
Go to the web project and click on properties, go to the 'Package/Publish Web' tab and uncheck the option
Over ride it from your build definition, click edit on your build defination, go to process tab and expand advanced and pass the following argument /P:CreatePackageOnPublish=false
HTH
Cheers, Tarun

In vs 16.5 go to project=>properties=>package/publish and enable it.
Web Deployment Overview for Visual Studio and ASP.NET

Related

What files are published when using Click Once deployment?

When I click "Publish" in my project properties, what files are actually getting published? I spent some time yesterday searching MSDN, but didn't find a clear answer.
I assumed (perhaps incorrectly) that it was publishing the latest version in source control, so I always made sure I had my changes checked in before clicking "Publish". But now I'm highly suspicious, based on a bug that was reported, that it has been publishing the Debug configuration on my laptop. I have code that should only execute in debug mode (#if DEBUG...), and it seems to be executing that code in production.
This is my first WinForms application and first time using ClickOnce deployment. Any guidance would be greatly appreciated.
What code is getting published? Latest in source control, most
recent build on build server or from local machine?
What settings do I need to set (and where are they) to ensure that my
application is published using the Release configuration?
TIA
UPDATE(S):
Here is what I see on the Publish tab
Does the Build tab come into play at all?
The Configuration setting on the Build tab is what matters when Publishing, correct? Not the selection in the toolbar?
For ASP.NET applications, when you go to publish, there will be a configuration option under settings:
The code you have locally is what gets compiled and published through Click Once. For non ASP.NET applications, the build configuration selected in visual studio is what ultimately gets published.
For this specific case, you have "Define DEBUG constant checked". That will cause the code marked as #DEBUG to be executed. It doesn't matter what the build configuration is if that is checked.
I tried on some settings on my project.
1) Select Configuration Manager by right clicking on your Solution.
2) When i clicked publish, here is what i get in output window
3) If you want to control what files (dependencies) are included as part of deployment, this can be controlled from Application Files button on the publish tab of project properties.
Here is an image.
Hope that helps.

Visual Studio project not building when I click debug or press F5

VS2010 c#, winforms project.
It does not build automatically when I click on debug or press f5. If I manually build the project before I debug, it compiles and changes are picked up.
My other projects all work as expected. Why doesn't it build automatically?
Right-click the Solution (not project) in the Solution Explorer and select Configuration Manager. Check if Build is turn off for the current configuration.
Check your settings in Tools->Options.
Go to the projects and Solutions area, Build and Run page.
There is a setting "On Run, when projects are out of date:" Make sure this is set to 'Always build.'
I ran into this same issue and I did the following:
Run Build Clean
Close the solution
Delete any .suo and .user settings files
Delete any .ncb files
Open the solution again
Unload the project
Reload the project
Make sure the project is set as startup again
Debug away!
You may be able to only do steps 6-9 but I don't know how to get back in that state.
Because my project was independend from other projects by using prism I had to uncheck 'Only build startup projects and dependencies on Run' in Tools->Options->Projects and Solutions->Build and Run.
When you work on a dependency
In my case, I am working on a library used by an executable.
It was necessary to say to the solution to include the dependency of the library in the executable project solution to build the executable code and the library code before launching the debugging:
Tools Menu, click on Options. Go to "Projects and Solutions/Build and Run", "On Run, when projects are out of date" needs to be on "Always build".
Right-click the Solution (not project) in the Solution Explorer and select "Project Dependencies". Check the boxes of dependencies "Lib1" and "Lib2".
Just in case someone else runs into the same problem as I did: for me it turned out to be a setting in my web.config as follows:
<httpRuntime fcnMode="Disabled" targetFramework="4.5" maxRequestLength="40960" executionTimeout="1200" requestValidationMode="2.0" />
What this guy does is he disables File Change Notification, which is used to restart the application domain when a change is detected in critical files e.g. anything in the bin or .config files. Without fcn, I would make code changes, press F5 and still see the old code, and all breakpoints would be whited out because the source was different to what IISExpress was serving up.
I had a similar situation with multiple projects in a solution in Visual Studio 2013. One of the projects that the Startup project uses was not building when I clicked the Run button. I had to right-click on the Startup project and select "Build Dependencies" and check the project that wasn't building in there.
Was scratching my head on this for a while, turns out our office's Folder Redirection configuration (e.g. My Documents to point to a Network location) did not integrate well with VS.

"A project with an Output type of Class Library cannot be started directly"

I downloaded a C# project and I wish to debug the project to see how an algorithm implementation works.
The project has come in a Folder, inside this folder there are -
.sln file and
a folder which has source files and a .csproj file.
I installed Visual Studio and opened the .sln file present in the main folder. I built the project successfully, but when I try to debug the project I get this message:
A project with an Output type of Class Library cannot be started directly In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.
The strange part is that I don't see a main function anywhere.
What should I do to get round this hiccup?
The project you have downloaded compiles into a dll assembly and provide a set of classes with implemented functionality.
You should add to your solution a new project with Output Type of either Console Application or Windows Application (VS Add Project wizard will offer you different templates of Projects).
In the newly added project, you can implement logic to test your Class Library.
Output type of the project you can find and change by the following steps:
Right click on project in Solution Explorer -> Properties.
In opened tab with properties select Application and there will be ComboBox marked with Output Type label.
Just right click on the Project Solution
A window pops up.
Expand the common Properties.
Select Start Up Project
In there on right hand side Select radio button with Single Startup Project
Select your Project in there and apply.
That's it. Now save and build your project. Run the project to see the output.
This was the solution that worked for me since I couldn't find 'Common Properties' option.
Select your topmost level project in Solution Explorer.
Go to Project, and in contextual menu Set as StartUp Project.
See also: A project with an Output type of Class Library cannot be started directly
Just needs to go:
Solution Explorer-->Go to Properties --->change(Single Startup project) from.dll to .web
Then try to debug it.
Surely your problem will be solved.
The strange part is that I don't see a main function anywhere.
That is exactly your problem. The project merely creates a DLL. It has no executable to run.
You will need to add a second project, which is an executable which references the other project, and calls something in it.
1) Right Click on **Solution Explorer**
2) Go to the **Properties**
3) Expand **Common Properties**
4) Select **Start Up Project**
5) click the radio button (**Single Start_up Project**)
6) select your Project name
7) Then Debug Your project
Right Click on "Solution Explorer" -> "Properties"
Expand "Common Properties"
Select "Start Up Project"
click the radio button "Single Start_up Project"
select your Project name from the drop down list.
If still not working after the above steps, then try this.
Expand solutions explorer.
Right click on project name -> "Properties"
Go to "Application" tab
Select "Output type"
From the drop down list select the appropriate type according to your application.
"Windows application" or
"Console application"
Then save (ctrl + S)
Try debugging (F5)
You'll need some kind of app (Console Apps are my favorite for debugging, but a WinForm will do) which uses your Class Library. Just add a new project (in the same solution) of a Console Application or Windows Forms Application, and add a reference to your current project. Once you've done that, make any calls you need, set your break points, and go to town.
I had a similar issue when trying to use the Experimental Instance of Visual Studio 2013. This was for a vsix project (Creating Snippets).
Solution was:
Right Click Project in Solution Explorer > Properties > Debug
Setting the Start Action to "Start external program" and using the following path:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
This option was set to "Start project" which won't work for the application output type Class Library, which caused that same error.
Note: Yours may differ depending on how you installed VS.
Error solutions is that you have already open your project but by mistake you have selected another class library .. that's reason this error is showing ... so what u need to do you u just select u r project then right click on u r project
after right click u can see the list box and select the "Set as start up project " option .
Accepted answer works if your solution has a project that compiles to an exe. If your solution does not have any projects that compile to an exe, then you have to use 'Start external program'.
VS2019 instructions:
right click -> properties on the main solution
debug, start external program, and add command line arguments
VS2022 instructions:
right click -> properties on the main solution
scroll down to Debug
Debug > General > Open debug launch profiles UI
left click the 'new' icon in the top left, select 'executable'
fill it out as per VS2019 (pick the exe and add command line arguments)
when clicking the start button, first select the profile you made
Suppose you have multiple project in the solution. Select the project that you want to view in browser and select 'Set as StartUp Project'. In your multiple project soln which was the main, the visual studio was unable to identify. this was the main problem.
You can right click the Class Library project and from the drop-down choose Initialize Interactive C# which will load your project context and you can work it in the interactive session.
In my case, the cause was that one of my projects in the solution wasn't loaded. The reason it couldn't load properly was that the file path length of one of the files was too long. Upon deleting this long file, I could reload the project, and build the solution.
If the question involves an Azure project, make sure you have the "Azure development" tool set installed, or when you go to run a solution you may get this same error.
Tools > Get Tools and Features... > Tick the box next to Azure development > Click install
None of the answers provided above helped me resolve this error, this is what resolved the issue for me.
Right click on the solution and select "Properties", which is in my case "Sintctech.Data".
Select the section called "Application".
Check what you have selected as your output type. If it is "Windows Application", change it to "Console Appication".
Rebuild and the problem should be fixed.

How do I remedy "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?

A C# desktop application (on the Visual Studio Express edition) worked, but then it didn't work 5 seconds later.
I tried the following:
Ensure debug configuration, debug flag, and full debug information are set on all assemblies.
Delete all bin and obj folders and all DLL files related to the project from my entire machine.
Recreate projects causing the problem from scratch.
Reboot.
I have two Windows Forms projects in the solution. One of them loads the debug information, one doesn't. They both refer to the assembly I'm trying to get debug information on in exactly the same way in the project file. Any ideas?
I want to add here, mostly for myself when I come back to review this question, that symbols are not loaded until the assembly is loaded, and the assembly is not loaded until it is needed. If the breakpoint is in a library that is only used in one function in your main assembly, the symbols will not be loaded (and it will show the breakpoint as not being hit) until that function is called.
Start debugging, as soon as you've arrived at a breakpoint or used Debug > Break All, use Debug > Windows > Modules. You'll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You'll get a dialog that lists all the directories where it looked for the .pdb file for the assembly. Verify that list against the actual .pdb location. Make sure it doesn't find an old one.
In normal projects, the assembly and its .pdb file should always have been copied by the IDE into the same folder as your .exe, i.e. the bin\Debug folder of your project. Make sure you remove one from the GAC if you've been playing with it.
Check to make sure that you are not in release but in Debug.
When in debug:
First try rebuilding your project by right mouse click the project > Rebuild
If that doesn't work, try a clean of the project (right mouse click on the project > clean)
If that didn't work check this:
Right mouse click your project
Select [Properties]
Select the [Build] tab
Make sure [Define DEBUG constant] and [Define TRACE constant] are checked
Make sure [Optimize Code] is unchecked
Click the [Advanced] button at the bottom of the Build tabpage
Make sure that [Debug Info:] is set to [full]
Click [OK] and rebuild the project ;-)
(step 7 generates the .pdb files, these are the debugging symbols)
Uncheck the "Enable Just My Code" option in the
Tools/Options/Debugging/General
Just something simple to try - you may have tried it already.
Right click the Solution in solution explorer, click "clean solution", this deletes all the compiled and temporary files associated with a solution.
Do a rebuild of the solution and try to debug again.
I've also had troubles with breakpoints multiple projects in a solution - some compiled as x86, some as x64.
The selected answer led me to fix my problem. But I need to do a few things more:
Even with "Debug" selected in the dropdown:
And in the project Properties > Build:
The Visual Studio was not loading symbols to a specific project. So in that dropdown I select "Configuration Manager" and saw that the settings to my web project was incorrect:
Then I set that to "Debug" and it started to generate the .pdb file.
BUT I need to manually copy the PDB and DLL and put in the folder that VS was looking (here is where the selected answer helped me):
Sometimes, even though it gives you this error, the Breakpoint still gets hit, so just ignore the error.
This happens fairly often in the Views of an MVC web app, i.e. .cshtml.
I was able to fix the error by simply setting the option in the 'Attach to Process' to 'Automatically determine the type of code to debug' option as shown in the attached screenshot.
Simply follow the steps below:
Go to Debug from the menu bar
Click on Attach to Process
Near the Attach to option, click on the Select button
The Select Code Type window will appear
Now select the option Automatically determine the type of code to debug and click the OK button.
Debug > Windows > Modules to see what modules were being loaded put me in the right direction.
In my case IIS Express seemed to be loading a different DLL from the temporary ASP.NET files.
The solution?
Browse to C:\Users\<YOUR USER>\AppData\Local\Temp\Temporary ASP.NET Files\vs
Delete everything in this directory!
Check if your .pbd file is missing in your bin/Debug folder. If it is then go to "Properties" of your project, selected "Build" and then "Advanced" at the bottom. Choose "full" under "Debug info" in the new window that appeared. This was my issue and solved it for me.
In my case "Optimize Code" was checked in my project properties. This caused VS to see my assembly as "not my code", and in turn, it did not load symbols for it.
The solution was to uncheck this.
Try running visual studio as an administrator within windows.
You need to enable "Generate debug info" in compiler settings
I tried everything mentioned above, but nothing worked.
[Clean solution, and check for PDB files etc.]
Even publishing the same solution did not resolve the issue.
Then I went to back to what I usually do to resolve (fool this stubborn Visual Studio)
All I did was to make a deliberate change in code and publish the solution.
Then I reverted the change and published again.
Voila [PDB files rid of evil spirits].. Not a smart resolution, but this did work.. :-|
We found the cause of our problem. This code was using the "CodeBehind" attribute in the Page directive of the .aspx file instead of the "CodeFile" attribute (ASP.NET 2.0 and beyond). After days of desperation, a simple search and replace solved the problem.
Option "Start debugging, Debug + Windows + Modules" does not exist in Microsoft Visual Studio Express 2013 edition.
Unchecking "Use Managed Compatibility Mode" in Tools Options Debugging fixes this.
Webapplications (IIS Express) only:
Rightclick IIS Express Tray and close the IIS.
Clean Solution
Clean solution and Rebuild
Check the configuration is set to Debug
Make sure that the PDB file is in the Debug folder it self
From Debug menu click Enable All Break points
Make sure you're in Debug and not is release by choosing debug in the dropdown menu like you can see in the picture below.
Then, try cleaning your project by clicking the right button in your mouse on the solution in the solution explorer window and choosing Clean solution.
Then rebuild your solution by clicking the right button in your mouse on the solution in the solution explorer window and choose Rebuild solution
Check are the following two setting the same in Visual Studio:
Right click test project, go to Properties, Build tab, and look at Platform target
Mine are all set to "Any CPU" so x64
On the Main Menu bar, go to Test, Test Settings, Default Processor Architecture
Mine was set to X86
Changing this to X64 to match above setting made the built in Visual Studio menu “Debug Test(s)” work and hit breakpoints that were previously ignored with the message “The breakpoint will not currently be hit. No symbols have been loaded for this document”.
Update:
For Visual Studio 2019 the menus have been moved around a bit:
I also had the same issue what I rebuild the whole solution (including refereced projects) in x86( or x64)
Even though I set all of my projects to x86 from Configuration Manager (Build->ConfigManager) some of my projects were not set to x86.
So Just to make sure right click on the project and follow
project -> properties -> Debug Tab, verify Configuration and Platform.
The .dll where I want to stop debugger and the associated .pdb files where copied near the .exe file. Those files had an older date so I thought they weren't updated in the runtime. I manually deleted them, Visual Studio create another pair AND put this new pair near the .exe. Now the breakpoint works!
Maybe Visual Studio cannot copy and REPLACE existing files (.dll and .pdb) near the .exe since there are another there. So if I deleted manually then VS could create new one near .exe.
I think that the root cause of the problem is that the Visual Studio use another file in runtime, no the file from the project, with the stop.
Instead of doing all these things just Close and reopen
Project Properties (then select your build config) > Build Tab > Advanced... > Debug Info (dropdown)
Set to 'all' or 'pdb-only' then rebuild
This took me a while tried other options above and for some strange reason debugging stopped working.
Tool -> Options -> Debugging -> General -> (untick) "Require source files to exactly match the original version" option
I was integrating a C# application with a static library using VS10 - which I'm new to. I wrote a managed code dll to interface them. I could set breakpoints everywhere but the static lib. I got the message described above - no symbols have been loaded for this document. I tried many of the suggestions above. I could see that the symbols weren't being loaded. I finally noticed a check box Configuration Debug, Enable unmanaged code debugging. That allowed me to set breakpoints in the static lib functions.
In my case, I was compiling a class library (DLL). No modules seem to be loaded in Debug -> Modules, so I couldn't even load the symbols manually.
My solution was to add this line to my code:
System.Diagnostics.Debugger.Launch();
Once this code is reached, an exception is triggered and .NET Framework shows a dialog box asking which Visual Studio (i.e. new instance of VS 2008, new instance of VS 2013, etc) you want to use to debug the program. You can choose the existing instance of VS with your project loaded. This will attach the process to your VS session and load all symbols, and now you can debug your project.
Of course, the compilation has to be done using the Debug configuration, not Release.
For an ASP.Net application, check the properties of the site, ASP.NET tab. Ensure that the correct ASP.NET version is selected.
I think the source if this error is, the debug symbols have a hard time surfacing to the solution after building for release.
I tried all the other answers -- generally, regenerating .pdb symbols or checking their location, cleaning and rebuilding project, ensuring active configuration is not Release etc.
What eventually worked for me is right-clicking on the project in solution explorer > Debug > Start new instance.
After trying a bunch of these, the thing that ultimately worked for me was this:
In Debug > Options > General, uncheck Enable Edit and Continue.
this happened to me after copy paste another webservice asmx file into an existing webservice, resulting in the same error when trying to debug the recently added service, to be able to debug I had to start without debug, then attach to the process. its weird but its the only way i found to be able to debug.

Remove ClickOnce from a WinForms app

I have a WinForms application that was going to use ClickOnce. But it turns out ClickOnce won't work for my application, so I'd like to remove it. Only...there doesn't seem to be an obvious way to do this. There's no "Un-ClickOnce" button. Does anybody know what steps I need to take to get my app to be like it was before ClickOnce integrated itself?
(I know I can create a new project and import stuff into it, but it seems silly to have to do that, so I'm hoping there's another way.)
Other responses here are not correct or helpful. It is incorrect to state that it never needs removing.
One such example I experienced recently was when the application had a need for administrative privileges. Any attempt to embed administrative requirements into the manifest will result in the application not even compiling while ClickOnce is still present in the solution.
The following two steps enabled me to turn off ClickOnce (in Visual Studio 2010):
In the project properties,
Signing tab: Untick "Sign the ClickOnce manifests"
Security tab: Untick "Enable ClickOnce security settings"
I agree with the others, there is no need to "remove ClickOnce".
If you are really going for it though, IIRC all ClickOnce settings are in the .csproj file for the project, so remove all XML tags there that relate to ClickOnce. (maybe easiest to compare to a new app that hasn't been deployed with CO ever to see what tags are not there)
If you refer the the ClickOnce Application Deployment Manifest files that appear in your Debug folder, go to Project Properties -> Security and uncheck 'Enable ClickOnce Security Settings'
You can also go to Project Properties -> Signing and uncheck 'Sign the ClickOnce manifests', but this is not necessary because it does not have what to sign if you do the first uncheck.
Now if you go to debug and delete .application files, at rebuild, there will not appear again.
I believe the only thing that is left from ClickOnce once you stop deploying it is file publish.xml that tells you about what you have deployed thus far and what version you are at. Otherwise there is really nothing there that need concern you, just deploy from the bin folders as you would without ClickOnce.
Just in case this helps anyone...
My problem was specifically that I had a dependant "Class Library" project that had the "sign the clickonce manifest" checked but disabled so it could not be unchecked. My solution was to:
Convert that project to a windows app,
Re-open the properties panel,
Remove the click once manifest signing from the signing tab on the properties panel,
Convert the project back to a "Class Library".
I consider it an MS bug (still in VS2019 16.0.1 which I'm using now) but the workaround fixed it.
Good Luck!

Categories