Publishing website solution - How to stop a deleted file from being regenerated? - c#

I have a website solution in Visual Web Developer. I have replaced a new file with an older file of the same name. I understand that the default behavior for web deploy is to update only older files with new ones. However, in this case I have replaced the new one with the old one by right clicking it (the old one) and clicking 'publish myfile'. This did in fact save the old file as I want.
The problem begins when I later publish the whole website again (to update other files). Somehow - this older file, which I want on the server, is replaced with the newer version - the one that at least theoretically, doesn't exist neither in my files, nor on the server! Where does it come from? And how can I stop that from happening?

I've found a solution, though not why the problem exists.
Open the folder and make a copy of the file. Then, in solution explorer - delete the original. Publish. Rename the copy to the original name. Publish again.
There may be unnecessary steps here. I'm just posting something that worked.

Related

Removing a view from .NET MVC project that is no longer needed

There is a view in my MVC that is no longer needed and I would like to remove it properly beyond just taking away the button that allows users to navigate there.
There are the ActionResult functions in the associated Controller as well, and when I removed these functions as well as deleting the view.cshtml file, I encountered an error when I attempted to deploy the changes because the build was looking for the view.cshtml file that had been deleted.
I'm guessing there is a config file or something similar that has all of the various pages/references included and that is where the deployment is failing.
You need to be sure to delete the view from the project and not just the directory. In VS just right-click on it and delete it.
Also be sure to save your project and that the updated .csproj gets sent to your build server.
the file could possibly still be defined in the .csproj file if you didn't delete it within VS this would still be there and if you didn't deploy the change to the .csproj file also it would still be looking for the file in question

SVN renaming files to uppercase after merge

some background: I work on Windows 10 and have a C# project that contains some .cs files like Foo.cs, which are mostly (but not exclusively) auto-generated from database tables by the Entity Framework. Additionally I use SVN (with TortoiseSVN) for version control.
So recently, after merging another branch, I noticed that some files went "missing". After checking them in the explorer, I noticed that they were renamed to entirely uppercase, e.g. FOO.CS, even though they were not renamed just modified in the branch I merged. Even stranger: When I tried to rename FOO.CS back to Foo.cs manually through the Windows Explorer, the file name instantly changed back to FOO.CS. Which files were renamed seemed random to me and I don't see anything that makes the renamed files different to any of the other files.
I am really clueless to what is happening here and this problem keeps re-emerging constantly in my Entity Framework project forcing me to manually copy changes to my branch (yuck!). At the moment I suspect SVN or TortoiseSVN to be the culprits here, but I might be wrong (maybe Visual Studio is messing with my file names, or it could be me doing something stupid?).
I couldn't find any threads about my problem, so any help would be much appreciated.
Well, turns out that Subversion wasn't the true culprit. The real problem was my local repository folder which was stored on a FAT32 drive. Apparently FAT32 does not distinguish between upper- and lowercase characters for file names and a newly created file named TEST.TXT shows the same behaviour as the FOO.CS I described in my question.
So using another file system like NTFS should solve my problem.

ASP.NET website in production goes down after while (Could not load file or assembly...)

I have problem with web site which is made in asp.net, in dev everything works fine, but since I published it to a server, I faced next issue :
After some time some items appeard in my folder called "Temporary ASP.NET Files" and I realized when there is few stuffs web site goes down and it shows this screen:
And what I saw in my TEMP folder was next:
AND TEMPORARY SOLUTION WAS TO DELETE FILES IN THAT FOLDER BUT AFTER WHILE THEY ARE AGAIN THERE AND SITE GOES DOWN.
I TRIED WITH PREVENTING USER TO WRITE THAT FOLDER BUT THAN I GOT ANOTHER ERROR WHEN I TRY TO ACCESS MY WEBSITE, SOMETHING LIKE :
...can not write to ... folder..
Thanks guys,
And kind of suggestion will be really great!
Thanks!
You have to add the XXXXX.dll files to the bin folder on your server.
Some times (I don't know why) some DLLs are not part of the project and you have to copy manually. If the file(s) already exists, you can replace the file with your local DLLs.
Check:
1. Project Framework VS Application pool.
2. Check all Dll's if include and its framework too.
3. Check eSavez_Servis Framework.
Just simulate your problem one by one.

Files show as hidden in Visual Studio 2012

Hei,
So we have a whole group of people working on the same project and every now and then some files show as hidden, you know the blank file icon like obj or bin.
See my font and texture? They should be normal.
So, I can see them in the folder but not in solution explorer without hitting the Show Hidden Files. I can also modify them but I would like them back.
I have been trying to see if there was a solution but all I get is blogs on how to show hidden files.
So I found this thread
Visual Studio 2012 and missing files
that seems to be giving the reason of my problem. People are not saving properly before pushing to github.
Now is there a solution to this?(apart from saving properly) Can I make all of those files become normal files?
Cheers
Simply right click the files/folders and include them to source control again.
This usually happens if people check in new files/folders but do NOT check in the updated project file, too. The project file contains a list of all files which should be included within the solution. If this runs out of sync, exactly this crap will happen... ;)
Simply instruct your folks to properly check-in. Or do code review on check-in and verify that the project/solution file(s) are also checked in.
They show up as hidden because they're not part of the project/solution, but they are on your file system.
You can right-click the files and click Include in Project
If this does not solve the issue after checking in. The project file is what is not properly getting checked in.
Probably the problem is that they are not pushing the project file (file with extension .csproj). It holds all references to files included on the project so it needs to be pushed when new files are added.
Let everyone know that they need to push this file in order to everyone to catch latest changes on project.

Altering 1 C# controller file

I've worked with PHP but never C#, and I need to make 1 change to a file, and was hoping I could get some guidance, or suggested resources to learn more.
I have 1 cs controller file where I want to change the [Authorize(Roles="A")] to [Authorize(Roles="A,B")]
I made the change but nothing happens, so I've come to the conclusion that this cs file probably needs to be compiled.
The question is, is there a way to compile this one file? Or does the entire site need to be compiled?
When I open the cs files, it opens with "Visual Studio Tools For Application 2.0 2008".
Is this sufficient to make the changes?
My thinking is that one of the following needs to happen:
Scenario 1:
Open the .cs file in the appropriate compiler (of which I do not know
what it is) Compile it and copy the newly compiled file into the
appropriate folder.
Scenario 2:
Open the whole project in a compiler - of which I'm guessing the
".csproj" file to open. Compile the whole project Copy the desired
compiled file to replace the old file.
Scenario 2b:
Open the whole project in a compiler - of which I'm guessing the
".csproj" file to open. Compile the whole project Copy everything
back to the server.
Scenario 3:
The code I have is not sufficient to do the changes, and I need some
other source code.
That's all I've got, if someone can suggestion which one(s) may be on the right track, and how I may go about doing this, it would be greatly appreciated.
Thanks
The fact you are talking about a Controller would strongly suggest you are working on an ASP .NET MVC project. You will have a .sln file which is a solution file which is the master document if you will:
YourWebsiteSolution.sln
YourWebsiteProject.csproj
YourController.cs
Once you open the .sln file with Visual Studio (you need to know what version but you can get the latest here: Download VS2012 Web Express). You can the choose Build -> Build -> ReBuild Solution from the menu and that will re-compile all of your .cs and associated files into DLLs that will be in your \Solution\Project\bin\Debug folder (or Release depending on build).
When you deploy to the server you only deploy the .DLL files (in this instance). You NEVER deploy the actual .cs files as they contain the code and you don't want people peeking into them (this differs from PHP where the code is on the server).
Because you have not changed any of the views you don't need to follow this step but for a full deploy you would also copy any .cshtml or .aspx files and the usual suspects such as .css and .js etc to same folders on server as on the project.
I hope that is a good starter to get you going?

Categories

Resources