Build action is not supported - c#

No code, since it's not a code problem, rather a visual studio one.
I've searched this problem up a bit and found people saying they had this problem, not really specifying how they got it, and most people answering "you should set AndroidManifest.xml's build actions to none" without any explanation of why this would work, which, well won't work for me since it's already what I have and I'm getting the error anyway.
How I came to have this problem:
I made a few files, file1, file2, file3, in my assets directory.
I would then read them with a streamreader. This worked.
Fast forward a few weeks, I decide to rename them, through visual studio, to file1.txt, file2.txt ... etc.
When I compiled/launched it on my device, it did not work. An exception on streamreader told me the file wasn't found. And before that I had 3 errors "#(Content)build action is not supported" for each of my files.
I assume the problem lies in the build actions or possibly the way android behaves with some specific files? Either way how could this have changed by changing the file format? I made them .txt files for clarity purposes, I didn't expect everything to break down after that.
Ontop of that, I could not revert it. I removed the file extensions, and I still have the same problem now.
What should I do to have my files in the assets folder properly deployed on my machine just like they used to ? Is it related to the build options?
Thanks in advance.

As highlighted by Jason in the comments above, the build actions for android assets should be AndroidAsset, which got changed after I renamed them. This menu can be found on the properties of the file.
https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/resources-in-android/android-assets?tabs=windows

Related

100s of errors that all go away when I view them?

I have hundreds of errors saying type or namespace doesn't exist (some are types and some are namespaces). When I click to view the error it initially opens the file and shows the squiggly line under code in question, however within a second or two the squiggly line disappears and so does the error.
After I finish opening up all the files with "errors", all the errors disappear and it compiles fine. However, if I close any the files then the error reappears for that file.
This happened after I tried to merge branches. Not really sure how to proceed to find the root of the issue, or whether there even is a real issue... maybe this is just some bug in Visual Studio and I need to do something to clear some kind of cache to fix the problem?
Please advise.
Update:
I have tried all of tymtam's suggestions but to no avail.
However, after deleting the .vs folder, now the errors don't even go away when I open the files so I can no longer build by doing that either.
I am thinking the error may have something to do with dll versions or something like that but I have tried to rebuild and replace all dlls with latest ones and that hasn't helped either.
The problem for me was an outdated version of the .net framework. The new assemblies I was referencing were 4.8 based but my projects were targetting the 4.6.1 framework. Updating the project files to target 4.8 fixed it.
IntelliSense, which is likely the source of these errors, sometimes takes time to adjust to changes caused by switching branches (or more generally code changes that happen suddenly).
Here are the steps that should help, in order:
(Re)building the solution
Restarting Visual Studio
Closing Visual Studio and deleting .vs folder in the root of the solution folder.
Finally you can see if the errors are 'real' by changing what the Error List window shows to Build Only. I would recommend to have it as 'Build + IntelliSense' normally, and using Build Only only on special occasions.
Focus on the 1st error
More generally, when dealing with a large number of errors it's not a bad idea to look at the first one only, solve it, and build the code. A single syntax error can result in many errors and trying to solve the 2nd and subsequent errors would be futile.
In addition to the above, make sure you also look at the warnings (possibly information messages).
In my case, I had them turned off to focus on the errors only and missed the fact that my two projects were set to different versions of the .NET framework.
I did these two things to fix my problem:
I used WinMerge to copy files from the old branch over everything in the new branch for the application in question.
I updated the framework on the project to the latest version.
Originally, I did those two steps except I used TFS to merge the old branch to the new (instead of using WinMerge to copy/overwrite files) and accepted the old version for all conflicts.
This was the nuclear option as I lost any changes that were made in the new branch :(. I have a copy that I can use WinMerge to try to manually merge changes back in but it's definitely frustrating.

Visual Studio Shows code errors that don't exist

I'm not sure if anyone else has encountered this but often, when I open this particular solution, I see a whole list of errors (see below).
If I double click one of them, then Visual Studio seems to wake up and the errors relating to that particular cs file disappear. This isn't a critical issue and is more on an irritation than anything else but I wonder, is there perhaps something wrong with my code that's causing this false-positive or is it random Visual Studio behaviour?
I had this problem too.
Deleting bin and obj folders not work.
Cleaning solution not work.
Various platform I need to be as is.
Helped me close solution and delete folder .vs, which is often full of problematic mess. After opening solution all false errors disappeared.
As mentioned in a comment, you can do a Clean and Rebuild. If that does not work for you, you can browse to the solution folder and within each of the project folders delete the bin and obj folders. Then perform a build.
You may also want to look into your Configuration Manager and ensure that all of your projects are set to the same Configuration (Debug/Release) and Platform (Any CPU/x86/etc...) and marked to build for that configuration.
Finally, you may also want to check the Build Order for your solution. Ensure that projects are all built in the proper order.
-- Edit:
On thing brought up in comments that I will add here was to make sure that any library projects in the solution are added as Project References rather than referencing the output DLL directly.
Something that has only become evident in later years, and is only relevant upon reflection on this old question, is that the particular solution that we experience this issue in contains a Website project and NOT a WebApplication project. This became evident when we started to look deeper into these recurring errors and noted that they only ever related to codebehind files and all had to do with the Control Name not existing in the current context.
Amongst the various differences between the two project types, it seems that the lack of designer files for each ASP page may be a contributing factor. The error disappears as soon as you double click it potentially indicating that VS is not able to keep track of the control references until you open the relevant page / codebehind file.
We're moving over to a Web Application as a temporary measure.
Hope this insight helps someone else!

Source file in CSC cannot be found

After a struggle with creating a database (first with an entity framework, after without), we have a database (and an EntityModel_HFFContext file we don't use, it's not connected). Normal work proceeded, and I installed a NuGet-package for an MVC sitemap.
From that moment, the project worked fine, but after a couple of days two warnings came up about two files missing: "The parent file, 'EntityModel_HFF.tt', for file 'locatie.cs' cannot be found in the project file." ("HFF" is the project name in here) and then those multiplied themselves into errors: "Source file 'locatie.cs' cannot be found" in a CSC file I cannot find.
These two files ('locatie.cs' and 'klant.cs') are not in any view, but somehow they are displayed outside all folders, saying they do not excist (see this screencapture). I have tried to delete those files manually, but that did not have any success. I have tried some other ways too, but that resulted into the complete deletion of the database, so now I am somewhat desperate.
I have no idea where to look and what to do, to get rid of these two files (or probably references to these files, since we don't use them at all), so I don't have these errors anymore. Has anyone of you have a clue of where I need to look (e.g. where this CSC file is) and what I need to adjust to fix this?
Maybe it can be useful to know I use Visual Studio 2013.
Update
I fixed the errors by unloading the project, editing the .csproj file and commenting out
<Compile Include="klant.cs">
<DependentUpon>EntityModel_HFF.tt</DependentUpon>
</Compile>
(and the other one too). Now these errors are gone - is this a safe way to do this?
The reason why you get the error is because when you deleted the locatie.cs and klant.cs file, you didn't remove them from the project solution itself, therefore, Visual Studio is expecting the file to be part of the project but is unable to find them, which explains the yellow warning signs.
Like what you said, all you have to do is to remove the files from the solution as they no longer exists. So yes, it is safe to comment out that portion in the .csproj file.
Although, I would like to mention that you didn't have to go to that much trouble, all you had to do was to delete the file in your solution in Visual Studio, since they no longer exists anyway.

TFS on VS2010, merging code issues

Recently we have been having problems with TFS and our code base. We have a section of tests that use Webdriver, and a section that use Coded UI. Lately, we've been having problems merging our code after a new build has been pushed out. Some folders show up as a white outline of a folder, which we can right click and select "include in project". We also notice some files missing, and we can't "get latest" to grab them. We have to go some round about way to do it (shelve code, delete local files, get latest, merge code). Even when we do that we still have some issues.
But the main issue we are having is that our Coded UI maps are breaking. Instead of being the normal structure such as:
.uitest
----.cs
----.designer.cs
When we merge in the new code, the UI maps break out like:
.cs
----.designer.cs
.uitest
I opened the .csproj in notepad++ and noticed that both the .cs and .designer.cs files no longer have a dependancy of the .uitest file. Now the .cs file has no dependancy, and the .designer is dependant on the .cs file. We can fix it with relative ease, but it keeps breaking in every build and we have several maps we need to fix. What exactly could the problem be here? Also, referring to my frist problems of files not being included in the project, what could the issue be there?
I asked the same question on the MSDN forums, but the suggestions I have received I have already tried, like creating a new workspace since the other might be corrupt. Still didn't work.
Thanks in advance
Edit: Had a suggestion on the MSDN forums to run VS as administrator. That didn't work either. Not really sure what could be causing this issue. It doesn't seem to be causing problems for everybody because some new builds cause issues for some people but not others. Some more info would be I run on Windows 7 64bit and Visual Studio Ultimate 2010.
In the past I've had issues with TFS that sound similar, 2 of our developers seemed to periodically create problems when merging files into the data store, folders and files would show as not included while the project file would make it in (breaking everything after get latest). Eventually the problem went away but we never truly found the source. I believe it had something to do with our network - maybe a switch issue in combo with the way we mapped working folders to network drives pointing to a shared dev server. Also one of the workstations seemed to have a problem with windows explorer not seeing file updates on the dev server share... developer would have to hit \servername\C$\sharefolder then hit his mapped network drive again before updates would refresh. (And his check in's created the most problems) ... we ran VS2008, TFS2010
Just some ideas...

SVN keeps corrupting files with "<<<<<<< .mine", how to fix?

I've got a Visual Studio C# project which is under version control (SVN).
I've always commited and updated the project without any problems. But a couple of hours ago Visual Studio throws the following error when I try to launch/rebuild the project:
Files has invalid value "<<<<<<<
.mine". Illegal characters in path.
I don't know how to fix this problem. What should I do?
That happens when svn encounters a conflict: You changed a file, the file on the server was changed and it cannot (easily) be merged automatically. You need to decide what is the correct solution now.
Subversion just adds the diff into your source file (and creates files next to it, called OriginalName.mine (unchanged) and OriginalName.rsomething (unchanged, server version)).
Fix the conflict and tell subversion that this is resolved.
just delete the obj folder and it will worked fine.
Remove the code that shouldn't be in the file throwing the error and remove the the three files with extensions .mine, .<somerevision> and .<some_other_revision>. svn updated files that now contain 'conflicts' and you need to resolve these conflicts by hand. Usually this means you edited a file, someone else edited the same file and checked in changes and you didn't pay attention when checking out the changed file.
Delete every thing you have in obj folder .
Remove your obj folder from svn version control . Because on every build it get updated and when other developer commit changes to solution SVN is unable to marge obj folder files and raise error
Files has invalid value "<<<<<<< .mine". Illegal characters in path.
Please read the Basic Usage chapter in the subversion book. It has a section about Merging conflicts by hand which explains the conflict markers you're seeing.
Removing the debug folders worked for me (see comment-not answer above).
I got this after moving 12 folders from one section of svn to a new section. So if you get this after moving a project and the error does not point to an actual file, this is likely your issue.
If you have AnkhSVN or VisualSVN installed resolving this is most likely as easy as right clicking the file in the solution explorer and selecting edit conflict.
This will open the changed file in your merge editor. (See Tools->Options->Source Control->Subversion User tools for AnkhSVN). With a good merge tool like the free to use SourceGear DiffMerge or TortoiseMerge, resolving the conflict is just a few mouseclicks away.
I have had this happen on a large scale where the files get marked resolved but the conflict metadata is still there. I wrote a regular expression for visual studio to find these, for instances where it is not feasible to simply revert the changed files.
http://www.codetunnel.com/blog/post/90/ever-merge-with-svn-and-mess-up-when-resolving-conflicts-read-on
I closed the IDE, then deleted the obj folder and restarted the IDE and rebuilt my Code. This worked for me.
Inside your project :
odj folder -> Debug -> project name.csproj.Filelistabsolute.txt(snb.csproj.Filelistabsolute.txt)
Inside the text file
>>>>>>>.mine and >>>>>>>.r150 occurs
to remove the things the program works
1)Just save your local changes whatever u have edited in the file
2)revert the file
3)update it from SVN
4)Paste your local changes
If you are using TortoiseSVN you should have a right click option on the file called Edit Conflicts. This should bring up TortoiseMerge which is able to read those obnoxious notations stuck into the file (really, to break your code so you KNOW there's an issue and don't blindly check it in).
TortoiseMerge will read it properly and present you with a 3-way merge. This was what I was looking for. Although it is true that it does also create the separate .mine and .rxxx and .ryyy files, and there are various manual and command-line ways to deal with all this.
Have a simple solution. just delete all file from debug folder and rebuild the solution, an error display on the screen "There were build errors. Would you like to continue and run the last successful build? click on "Yes" button. Now stop the program and run normally.

Categories

Resources