Web.config Vandalized Mystically During Azure Deployment - visual-studio-2010

I know this is super weird, so to make you believe me and help me, I provide lots of evidence here.
Problem: the web.config file under site/1/views has been changed during Azure Deployment.
Facts:
The file exist in .cspkg package, not the case here
No other web.config been changed, not the root one, not the one in site 2,3,4.., not in area, not in any other places. The whole solution has 10+ web.config files, but only this one, the one under Views of site/1 has been changed.
File is not been replaced, is been edited, only change is 2.0.0.0 -> 1.0.0.0 and
4.0.0.0 to 3.0.0.0, which is a targeted vandalize, I have to say. Nothing else changed, my own namespaces defined still there.
Tried:
Remote Desktop to the Azure Instance, edit the file, the site works, and it won't change back even after reboot (except the reboot at Azure interface which whole package just reloaded)
Repackage and redeploy, twice, no use.
Changes I made from last deployment, which was a success one
Install Visual Studio 2012 Ultimate trial today
Upgrade the whole solution from MVC3 to MVC4, Azure SDK from 1.0 to 1.7
Change all project from framework 4.0 to 4.5, found Azure cannot support 4.5, then change back to 4.0
finally built and packaged
Whole package works well before under Visual Studio 2010
Whole solution works well in local as well
Pictures
pic1
Original web.config file under site(1) Views folder
pic2
It's in .cspkg package.
pic3
Check again from remote desktop
Final words
I know there's a solution is make site(1) empty, a dummy site, so whatever been changed will not matter. Or just load my backup and back to VS2010. But I do really really like to know how it got changed, and how to avoid it, thanks.

Related

Create Visual Studio 2019 project from existing Azure Web App

I have a v7 Umbraco instance as a Web App on Azure but the machine the dev copy was on has been decommissioned and I need now to recreate the dev site in Visual Studio 2019, ideally cloning it from the live site in some way. I have created an empty project and, using the cloud explorer, downloaded the files from the app, but I am unclear whether I just copy them directly into the solution folder or into their own subfolder of the solution folder or whether simply copying them in will do the trick anyway as there's still the database to consider as well. I'm afraid I haven't used Visual Studio since creating this site three or so years ago and I seem to have forgotten most of what I did then anyway, so any help wpuld be greatly appreciated. The only advice I coud find via google was for older versions of VS and so not much help.
Recreating the original project from the live site is probably not going to be possible. It depends how and what you deployed to the live site.
It sounds like what you have is a working live site, but have lost access to the original source code. You should be able to copy the site and get it working elsewhere, but you're probably going to struggle to recreate the original development environment and amend the compiled elements of the website without access to the source code.
The Umbraco.com website has some great documentation on getting started and setting up Umbraco. Umbraco TV is great for getting up to speed quickly too. This should help explain the project structure. I suggest you create a blank Umbraco install to familiarise yourself with how Umbraco works(I wrote a post explaining how to do this with MS VS2015 here).
A typical deployment, using MS WebDeploy or FTP from Visual Studio, wouldn't deploy the project files or source-code for the compiled (.cs) elements of the website, these are usually kept as development files and checked in to source control.The live site probably only has the compiled versions of these file in the bin folder. The good news is the Razor template and view files(.cshtml) should be on the server.
However, if everything was uploaded (it happens) then you may have a chance, in which case you can download the files, potentially open the project and try to run the project locally on the development machine. There's no reason why you can't install an older version of MS Visual Studio alongside 2019 if there's an issue with that version. Although, I suspect this isn't an option since you felt the need to create a new empty project. If this is the case you might be able to add any project files to the the new empty project and attempt to recreate the project that way.
Regarding the database. You're going to need a copy or backup installed on a Microsoft SQL Server (unless you used MS SQL CE which is file based). You should be able to download a .bak file from the server if you're using Plesk or connect remotely using MS Management Studio if not, it depends on the host (Azure will allow access via MS Management Studio). Umbraco will need the connection string configured in it's web.config, the one you downloaded may be trying to connect to the live server so be careful.
Long shot ideas:
If you're really desperate you might be able to reverse engineer some of your compiled .dll using a tool like ILASM.exe but it's not going to be easy;
Perhaps you could reference the .dll in a the new project and it will all work auto-magically?! but I doubt this will work as there will be two application starting points and you'll probably get a runtime exception.

How to work on an external developer's project using Team Foundation Server

Me - Front End web developer with an ok working knowledge of writing VB.NET code but I have never built a .NET project from scratch using Visual Studio.
External developer - Experienced VB.NET developer but completely new to version control and TFS. Also extremely cheap and prone to infuriatingly poor programming practices. He does things that make you bang your head on the table.
Background
Our external developer has coded our site but over the last few years I have been tweaking aspects of pages and have managed to learn quite a bit of VB.NET along the way. He has never used source control and I don't think he's ever had to work with another developer before.
Up until now he has maintained a local copy of the website. He makes changes to this local copy and when he wants us to test it he uploads the relevant files to our dev server. I have no experience of Visual Studio projects/solutions so if I have made tweaks to things I have edited the aspx/asxh/config files in my preferred editor and then uploaded them to the dev server. If everything works correctly I ask him to download them from the server so he can update his local copy.
I have been maintaining a local git repository of the website for the last 2 years. If he makes a change I check it in.
Obviously this is a nightmare to work with so we have now insisted that he starts using version control. I recommended GIT but he has decided to use TFS.
He has now put his solution and all the files into TFS. I have installed Visual Studio 2015 and successfully connected to TFS. I have mapped the files from source control to my own workspace but I am now at a loss as to what to do next.
Questions
As soon as I open the .sln file he has uploaded it says I have checked out the file and made changes. When I check the diff it seems to be because I am using a newer version of Visual Studio than he is. Does the .sln file need to be in version control? Or are we suppose to maintain our own versions of the .sln file and simply check in everything else?
If I try and build the project it fails because the web.config is set up for his machine and not mine. How can we maintain 3 versions of the web.config file? One for my local, one for his, and one for our dev/live environments?
I am not convinced he will have added the project to TFS correctly because he's never used it before. This is basically the blind leading the blind.
Question 1:
You need to put the .sln file in version control. Before check out the .sln file, please do a "get latest" step, which will make sure both of you are working on the latest version. When you try to check your local version in the server, and he had uploaded his local version in the server. You may have to solve conflicts before the check in.
Question 2:
You should build your project and published the website on the server. The build agent will only maintain one version of the web.config file. If he has built the project with his web.config. And you want to build the project again with your web.config, the build agent will delete the previous web.config and pull down your version. Then build the project with your's web.config.
Moreover, if both of you are not similar with TFS. Suggest you taking a look at below MSDN link which related to source control and build.
Use Team Foundation Version Control
TFS Vnext Build

Having trouble compiling an Orchard (v.1.5) project in Visual Studio 2013

First, I have no experience with .NET at all, I'm a front-end developer.
I agreed to help out someone with a website they own since they can't get in touch with the guy who originally set it up. It's running Orchard v1.5.1.0. I was under the impression that I could just download the entire wwwroot/ folder over FTP and open it as a webpage in Visual Studio (I'm using VS Express 2013 for Web).
Now, my problem is that while I can run the app just fine (I guess because I also got the bin/ folders with their DLLs when I fetched the whole thing over FTP) Visual Studio complains about compilation errors when I try to build it.
In one of the Modules, Amba.ImageMultipicker, there is a Views/Admin/Index.cshtml file that gets an error on the first line where it tries to do #using Orchard.Media.Services, and the error is The type or namespace name "Media" does not exist in the namespace "Orchard" (are you missing an assembly reference?).
(I have an Orchard.Media folder under Modules, so it's there. Somewhere.)
I have tried
Adding <add namespace="Orchard.Media" /> to web.config
Dropping the DLL from the bin folder in the Orchard.Media module into Dependencies
Verified that Amba.Imagemultipicker.csproj has a ProjectReference to Orchard.Media.csproj and that the relative path is correct.
Am I missing something extremely basic here? I really don't want to go back and say I can't help out, but if I can't get the flipping thing to run locally there's no way I am going to start modifying their Themes and hope it works on the production server.
Sidenote:
I thought it was wierd that I didn't get a bin folder for the module when I downloaded the entire site, and I notice there isn't one on the live production site either. Is it possible that the whole site is running with this error?

Opening a Visual Studio 2010 project in 2012 what creates the backup folder and how to control it?

I have an issue. We are upgrading to VS 2012 at work. When we open a VS 2010 project Visual Studio converts the project. This is fine, because VS 2010 can still use the project (yay microsoft). However, there is a \Backup folder created in the solution directory. Is this being created as part of the migration? Is there any way to control it?
The reason I ask is that the process that makes this folder copies web.config files into the folder. If you then try to build the solution (these are MVC projects), we get a "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." error. The cause is that there is a web.config file in a subfolder instead of the root folder. We did not make and do not want this change, and cannot figure out how to control it. Deleting the Backup\Web.config file fixes the error. Renaming it from web.config to web.config.bak fixes the problem.
I don't really want to have to personally open and convert every single project, and don't want random people bumping into this problem. Any idea how to either stop VS from creating the Backup folder, or how to make it create them in the my documents studio folder etc? I can't find any setting to control this and can't find any good info.
By chance, are you using the MvcBuildViews property to pre-compile your views at build time? If so, this is why you're encountering this (since it does the pre-compile in the same directory, it doesn't filter out any of the files below the project directory).
Note that you will also encounter this issue if you use the Publish feature for this project. Publish copies the web.config under your intermediate build output directory (by default, obj/) before and after applying web.config transforms.
The good news is that in VS2012, or in VS2010 with the latest Azure SDK installed, pre-compile is now supported for Web Application Projects (including MVC). These settings are currently in the project properties, under the Package/Publish Web tab.
(this doesn't directly address your question about the Backup folder, but it was too long for a comment.)
There is no way to control it that I found. We had to go ahead and run through and convert every project to 2012 and delete the backup folders to prevent any other team from running into it.

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