问题
I'm developing a Android App in VS Pro 2015(Xamarin). Everything worked fine until this morning when I updated my Android device. I'm able to build my application but while deploying to my device I get a bunch of warnings that say @(Content) build action is not supported which other people seem to have fixed by setting the AndroidManifest.xml build action to None but my AndroidManifest.xml's build action is already set to none.
I have checked all the specified files in the warnings. Most of them are .png with Build action set to Android Resource (I've also tried with Build Action -> Content with no luck) and a couple of them are .xml with Build action set to Content.
Here is the screenshot of my code window.
For duplicate markers: I have already tried the Xamarin posts related to this on stack exchange. Hardly there should be 20 posts! But none worked out for me.
回答1:
Open project folder and remove bin and obj folders, remove application from the device and try one more time.
回答2:
Right click on the AndroidManifest.xml and then select "Properties".
In Properties Window -> set "Build Action" as None
I take it as reference, hope it helps.
回答3:
If the file is android resources you need to get the property of the mentioned file and set:
Build Action: AndroidResource
Custom Tool: MSBuild:UpdateGeneratedFiles
Then recompile and when you get the warning again, just double click on the warning to open the text file associated with it, Make sure to delete this file from your project. This file will not be generated again. (You can find the file location by hovering your mouse on the file tab title).
回答4:
I had five pictures for image button, it worked fine.Being lazy, I copied the code to another project for reuse and (all the 5) pictures were not showing and I got the warning @content build action is not supported I just thought why other pictures (pictures which I had inserted new as per procedure) are showing up? right clicked them and saw their build action to be AndroidResource I changed the BuildAction of my (problematic) button pictures to AndroidResource and voila it is working
回答5:
In addition to the AndroidManifest.xml, the Build Action of the AssemblyInfo.cs also needs to be set as None.
The Build Action of all the Layout files should also be set as AndroidResource.
After that, it's always good practice to clean your solution then rebuild it
来源:https://stackoverflow.com/questions/45027774/xamarin-content-build-action-is-not-supported