Visual Studio for Mac - AppResource.Designer.cs Not Getting Regenerated - visual-studio-mac

Visual Studio for Mac Community 7.7.4 (build 1)
I went info one of my .NETStandard 2.0 projects and added a string MyLabelTitle to its AppResources.resx file.
I reference this string in my code like so:
AppResource.MyLabelTitle
This will build successfully and that is great.
However, lots of online forums, documentations, Xamarin forums, StackOverflow questions that I have seen state that AppResource.Designer.cs file will regenerate itself when you rebuild your project. Some suggest ignoring it in git as well.
To test that, I reverted back my changes (I am using git) from AppResource.Designer.cs so the end result is that:
AppResource.Designer.cs does not have my changes while
AppResource.resx file has my change in it.
Based on my understanding, rebuilding the project will pick up my change from AppResource.resx file and add it to AppResource.Designer.cs file.
However, building my iOS or Android project will now fail to build because it is referencing one of strings I added in AppResource.resx file.
This string is still present in AppResource.resx file but it wasn't regenerated inside AppResource.Designer.cs and as a result my project is unable to reference that string.
UNSUCCESSFUL ATTEMPT TO SOLVE
I thought that if I comment out the line of code referencing AppResource.MyLabelTitle, I should be able to build successfully and it did build successfully, but the string MyLabelTitle still was not picked from AppResource.resx file and re-generated inside AppResource.Designer.cs file. As a result, I cannot reference that string anymore in my code.
How to resolve this issue?

I suspect you also posted this problem on the Visual Studio for Mac community forum but will answer it here in case anybody looks here instead.
Visual Studio for Mac does not re-generate the associated .cs files for .resx files when building. It will re-generate the .cs file when the .resx file is saved in the text editor.
One problem here is that the .resx file needs to have unsaved changes otherwise the .cs file will not be re-generated.
Android projects will re-generate their Resources.designer.cs file on building. This .cs file is generated based on the contents of the various .axml files in the project not any .resx files.
There is an addin you can install which might help here. It provides a way to run all custom tools for the solution or project manually or when a build is run.
https://github.com/mrward/monodevelop-run-custom-tool
https://addins.monodevelop.com/Project/Index/380

Related

Port Xamarin Android project to .net6.0-android

I have a Xamarin Android Project that I want to migrate to .net6.0-android so I can use the new versions of MvvmCross. I have tried the upgrade-assistant. It claims to only upgrade Xamarin forms apps. I tried try-convert and it only seems to use msbuild through .net5.0. Can anyone tell me the correct steps to do this migration?
Thanks,
Jim
I wanted to maintain consistency in my Git Repository, so here is what I did. I made sure my app used the new PackageReference (to do this, if your project has a packages.config, you can right click it and it will give you an option to migrate). I created a blank .net6.0-android app. I copied the contents of my original app .proj to notepad to keep track of what NuGet packages I had been using. I then overwrote the contents of my original app .proj file with the contents of the blank app .proj. I used Nuget to add back in the required packages. I had to delete AssemblyInfo.cs in the Properties folder and Resource.Designer.cs in the Resources folder. I deleted the obj and bin folders in the project folder. After that, I was able to compile and run fine.

Website builds but publish to Azure fails after deleting files

Using Visual Studio 2019 to build a .Net Core website and publish to Azure was working fine up until I just deleted a DataContext file and an Entity class through Visual Studio. I can build and bring the site up locally without any issue but when I try to publish the site to Azure I get an error that the two files I deleted could not be found. I've checked in my code along with the solution file. The message is correct, those files are no longer available but I'm not understanding why it's looking for them since I deleted them through VS and the solution/project file should have been updated. I've done some searching but can't find anything that specifically address this. I guess I could roll back to right before I deleted the files but then I'l have to update some code. Anyone know if I can look somewhere that is referencing these files for publishing so I can delete the reference? I've searched the whole solution for the name of the files hoping I could find a reference but it isn't finding anything.

How to rename C++ source files in Visual Studio 2003?

I have several C++ projects in a few separate solutions in Visual Studio 2003.
I need to rename several of the directories and source-code files in these projects.
How do I rename directories and source files such that VS will recognise the new names?
If I change file names in the OS, VS ignores them. It still shows the old file names in the Solution Explorer, and double-clicking those produces an error message (something like "Could not complete the operation").
The Solution Explorer doesn't seem to provide any way to rename files.
I can select a file and see properties such as what file-system path it points to, but I can't change any of those properties.
I'm not using integrated source control.
I solved the problem in a few ways.
If I rename a directory containing a project used in a solution, I can either edit the SLN file directly, or open the solution in Visual Studio, then remove and re-add affected projects.
If I rename a source file used by a project, I can edit the VCPROJ file, as this contains the paths of all source files in that project.
I also had to check all projects for "Additional Include Directories" and "Additional Library Directories". Some of these referenced renamed directories.
I eventually fixed most of these using a separate text editor's "Find in Files" function to find directory references. This was faster than using the VS UI to check properties of each project.

Where does the VS2012 Publishing Wizard get its file references?

I am having an issue where when I select to publish my MVC project to the file system so I may upload it later via FTP to my Web Host, it fails complaining of missing files.
Believing that it may think these files are required to compile the project, I copy them to the locations that it expects and it resolves the error but produces yet another error about another missing file.
These files incidentally are not required to run my Web Application but were simply files used during the initial test phase of my project. More specifically, picture files.
The next step I took to resolve the issue was to Clean and rebuild the Solution and Project Entirely with all those files it was referencing in the errors removed. The Project builds successfully and runs as expected.
I then attempt to publish to the file system and again it complains of those files as if its getting that information from somewhere other than obvious places within my Project.
I have deleted the object directory content, cleaned and rebuilt; again it references these files that don't exist anywhere within my Solution.
So my question is, Where exactly does the Web Publishing Wizard get the information it uses to copy the required files to the Target Location? I've checked the .pubxml file but there's nothing in there that would provide the information.
For instance, if I'd initially built my site using reference to a .png file then later use a .jpg file. The Wizard seems to be getting the metadata for the initial build somewhere and insists on inclusion of the .png file when it is no longer needed.
I believe I have Upgraded to the latest build and patches for VS2012. I am Currently running version 11.0.50727.1 and using .NET 4.5
I cannot find any relevant information on this problem so it may be a quirk in my Environment so I'm searching for some feedback.
If no answer can be provided, if I could simply know what folders and files are required to deploy an MVC site; I'll perform the deploy manually and trash the Wizard concept. I just thought it would be the most appropriate way to deploy but if its going to be a pain; I don't need it.
This is the Error:
Error : Copying file <relative path>\image.png to obj\Release\Package\PackageTmp\<relative path>\image.png failed.
Could not find file '<relative path>\image.png'.
The new file that replaced the old file is actually image.jpg and its in there. I could alleviate this error by copying the old file back to its initial location, but why should I if its no longer required?

Project wants to check out .dtproj in SSIS project every time TFS Get Latest is performed

Using Team Foundation server and BIDS 2008, I receive a screen to check out the dtproj file every time the Get Latest operation is performed.
Steps to Produce:
I have no files checked out after performing a "Get Latest" from solution explorer.
I click to open the solution file .sln from Solution Explorer and the SSIS project opens.
I then receive a "Check Out" screen asking me to Check Out the .dtproj file.
Any ideas how to keep this from happening?
Imperfect answer: How can I prevent BIDS from automatically checking out SSIS packages?
Also related: http://social.msdn.microsoft.com/Forums/en-GB/sqlintegrationservices/thread/654d556f-3826-4fd3-a36a-e7f20a059569
I have been using BIDS 2008 with TFS 2010 for quite sometime but never had the issue that you are facing. Here are the Source Control settings on my BIDS environment.
Some of the other links that might help you:
A project is automatic check outs everytime when i opens the solution in TFS 2008
How to stop Visual Studio from "always" checking out solution files?
This behavior appears to stop if you manually add the .database file to TFS through Source Control Explorer, making sure that the .database filename inside the .dtproj is the same name as the file you add to TFS.
Turns out the .database file is a local 'runtime' type file that Visual Studio creates each time. It is not an actual source file and should not be checked into source safe. What I think happens is that:
This file gets created by VS
At some point someone checks it into source safe, making the file read only in their working folder
Next time VS tries to create the file again. It can't (unless it's checked out) so it creates another one with a slightly different name
Because the filename is now different is changes the .dtproj file that references it. It therefore tries to check the .dtproj file out because a change has automatically been made to it
Chaos and confusion ensues
This is roughly what we did to fix this:
Delete any .database files from source control, ensure that it never gets added back again
Close VS
Backup and delete any .database files from local dev folder
Open VS and get latest
You might get 'this project couldn't be loaded' type errors in VS because the referenced .database file is missing
To get the project loaded, you need to get a valid .database file (these can get corrupted - check the file contents) into your local folder, and edit the .dtproj file in a text editor to point at the valid file
Once you have your .dtproj file working, check it in and have everyone get latest
Make sure no one ever checks in the .database file
Why oh why is it called a .database file when it has nothing to do with a database. When you search online for .database you get...... information about databases, not this annoying VS file.

Resources