Xamarin.Forms安卓项目编译错误:Csc任务OutputAssembly参数异常
Hey there, sorry to hear you're stuck with this CSC task error after resolving the earlier IO exception in your cross-platform Xamarin.Forms project. Let's go through practical fixes to get past this issue:
Clean and Rebuild Your Solution Thoroughly
- First, right-click your solution in Visual Studio and select Clean Solution to clear existing build artifacts.
- Navigate to your Android project's directory manually and delete the
binandobjfolders—sometimes the IDE's clean command misses leftover files that cause conflicts. - Rebuild the solution, starting with your shared/PCL project first, then the Android project.
Verify Android Project Output Settings
- Right-click your Android project → Properties → Build → Output.
- Double-check that the Output path field only contains a single valid directory, with no duplicate entries or extra semicolons.
- Head to the Advanced build settings (under the same Build tab) and confirm the Output file name isn't configured to generate duplicate assembly files.
Manually Fix the Project File (.csproj)
- Close Visual Studio entirely, then locate your Android project's
.csprojfile and open it with a text editor (like Notepad++ or VS Code). - Search for
<OutputAssembly>entries—you might find duplicate lines pointing to the same DLL path, like this:<OutputAssembly>obj\Debug\Test.Droid.dll</OutputAssembly> <OutputAssembly>obj\Debug\Test.Droid.dll</OutputAssembly> - Delete one of the duplicate lines, save the file, then reopen your solution in Visual Studio and rebuild.
- Close Visual Studio entirely, then locate your Android project's
Check for Duplicate References or NuGet Conflicts
- In your Android project's References section, make sure you don't have duplicate references to
Test.Droid.dllor any related assemblies. - Open the NuGet Package Manager for your solution, check for any outdated or conflicting packages, and try updating them or reinstalling the Xamarin.Forms-related packages.
- In your Android project's References section, make sure you don't have duplicate references to
If none of these steps resolve the issue, you could also try resetting Visual Studio's component cache, or even creating a new blank Xamarin Android project and migrating your existing code/files over—occasionally project files can get corrupted in hard-to-spot ways that cause these odd build errors.
内容的提问来源于stack exchange,提问作者Deep Soni

