Visual Studio Publish gives different binaries to build - c#

I usually deploy my web application by right clicking on the app and selecting the publish option. VS copies everything to a local file system folder then I zip it up and copy it to the web server.
For some reason when I publish my branch the binary in the publish folder is different from the binary in the local build folder. It's as if it's building different code.
Both the local build and the publish are using Debug (Any CPU) configuration.
Here's a screenshot of the decompiled assemblies.
This first one is the one from the project bin folder and runs perfectly.
This one is from the publish folder and as you can see it contains some lines which aren't in the other build.
This particular class doesn't have any #IF DEBUG pragmas in it.
I've tried clearing out the bin and obj folders with no success.
Does Visual Studio have a cached copy of all the code somewhere that it uses to do the publish build that I can clear out?

Are you sure you have Debug configuration enabled in Publish settings? Publish settings override current Visual Studio project configuration.
Having Debug publish configuration enabled, publishing applies the Web.Debug.config transformations over Web.config, while local build ignores Web.Debug.config. As I see, you miss the NewJobRegisteredObject in published assembly, you may have xdt:Replace section in Web.Debug.config removing object registration.

Related

Publishing a .csproj through TFS visual studio build task

For the software at work we have multiple projects in a solution. Most of the project we can just build the solution and then publish artifacts of the web project that we need. API and Auth projects are slightly different though. Our currently deployment process is manual and for the API (STARS.API.csproj) and Auth (STARS.Auth.csproj) project when would go into Visual Studio 2017 and right click the project and click publish, select a profile and then publish. Once that is done we take the Publish Output and drop those files on our server.
We are trying to move to a automated process through TFS and I am using the Visual Studio Build task in a build definition. However when I try to run this through TFS, an error saying that the publish profile cannot be found:
Validating PublishProfile(TFSProfile.pubxml) settings. C:\Program
Files (x86)\Microsoft Visual
Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(4368,5):
Error : The value for PublishProfile is set to 'TFSProfile.pubxml',
expected to find the file at
'C:\agent_work\4\s\STARS\Source-dev\STARS.Web\Properties\PublishProfiles\TFSProfile.pubxml'
but it could not be found.
It is looking for publish profile in a different project folder.
Visual Studio Build Task:
I feel that I can approaching this completely wrong. I am just trying to replicate the process on publishing the project through Visual Studio 2017 manually.
Please let me know if you require more information.
I suggest you start using the pre-defined build variables. $(Build.SourcesDirectory) will map to C:\agent_work\4\s, and from there you can create a full path to the TFSProfile.pubxml, where ever it might be in your source tree. Use this full path in the MB Build Arguments, PublishProfile property, e.g.
/p:PublishProfile=$(Build.SourcesDirectory)\STARS\Source-dev\STARS-API\TFSProfile.pubxml
Another problem you may have is that in the Solution field you are not specifying a solution (.sln) but a project (.csproj). I suspect that MSBuild is picking up the solution associated with that csproj, and building the whole solution, which is why it is looking for a publish profile in STARS.Web. Have you created a publish profile for STARS.API?

How to deploy a "Release" build of an ASP.NET MVC5 application

So It's the first time I'm trying to deploy an ASP.NET MVC application to a Windows host.
I set the compile mode to "Release" in Visual Studio 2015 and I compile it but don't know which folder(s) to zip and upload to server...
I see an obj folder in project directory that has two folder inside it. "Debug" and "Release". I'm not sure about them though.
On the other hand in project directory root, there is a folder with the same name as project, inside it I can see controllers so I'm pretty sure that folder is not a "Release" build.
My host is running Plesk and IIS 8.
What should I do?
You should use the Publish wizard of visual studio. As a shortcut --> Right click on the MVC project and click publish. You will find many option here.
Make sure you configure your publish profile in release mode if you are publishing on server

Do we need to add the files in the debug/release folder to create a setup in Visual Studio?

I have created a setup file for my Winform project in Visual Studio 2013 but it won't run after the installation. When I use debug or release mode in Visual Studio, it will run.
A closer investigation, I found out that there's lot's of .dll, .config, .cs, .bin, .manifest in the debug folder as well as the release folder. I think they are the files created when I run debug mode or release mode.
Do I need to include all these files from the debug/release folder to the setup file system when I create my setup? Any idea how to check why my app won't run?
The files in the Debug folder must not be distributed, it is against the terms of you EULA for Visual Studio.
You need the release files and unless you are running on the build machine you may need some extra dependencies, You will be told about these in the error messages that are displayed.
More than that I can't help you with, because you haven't said what the error is, unless its no error in which case check your shortcut.
If the Application runs fine in the Debugging Mode of visual studio, then it means that you are not creating the setup file properly. You have to manually add all files that appears in the
../bin/Debug
folder of your project to after adding the primary output.

Visual Studio 2013 deploy without installer

I'm developing a Windows app in Visual Studio 2013. When I use the publish feature, it creates a setup to install the app.
I don't want it to create a setup. I want it to build and deploy into a test environment, ready to be executed, without overwriting that environment's app.config. It would be great if I could configure multiple environments and choose which to be deployed.
I found https://msdn.microsoft.com/en-us/library/hh191495%28v=vs.120%29.aspx but it requires TFS. I wanna do it directly in VS.
To make it more clear, the best solution would me to type F6 - or any other shortcut - and have Visual Studio do the following:
build solution
copy exe and dlls to a specified folder
don't change destination's app.config
if possible, copy also source code so that debugger when opened is able to run thru it
It should be able to configure multiple profiles, so that it can send files to multiple test environments.

Debug folder is automatically created on opening C# console application in visual studio 2008

I tried to create new project which is C# console application in visual studio 2008.
I have used Configuration manager to add x86 and x64.
And then selected Configuration as Release and Platform as x64.
Even though when I empty the contents of bin and obj folder after closing the project.
When I open the project debug folder is created in bin and obj folder.
How to avoid this ?
EDIT : If I build / rebuild after empytying the contents bin and obj folder, debug folder is not getting created. It is created only after the re opening the project.
EDIT 2 : Debug and release folders are created inside x64 and x86 apart from this I am seeing Release and Debug folder inside bin and obj. I am not sure which architecture this debug and release folder belongs to?
I have found the solution, removing Any CPU from target is enough to achieve this. Click on edit and then remove Any CPU from platforms. After which Only the active platform and target folder will be created

Categories