Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Let's say I have something using $(SolutionName) or $(SolutionDir) in my csproj.
From Visual Studio UI, Build will work fine.
However, during deployment on Android device (package creation) the variables will be undefined.
Can you show me a log, or screenshot of where the problem happens?
Let's say I have something like that in my .csproj:
<Import Project="$(SolutionDir)\Test.targets" />
This .csproj will load fine if it's a normal .NET dll, but if it's a Mono Android project, it will complain that C:\Test.targets doesn't exist at project load time (because SolutionDir is not properly set). The project will simply not load and appear as unavailable.
As a workaround I currently set SolutionName and SolutionDir before opening visual studio, but that's really not user-friendly for deployment.
Also as far as I can remember I think that there was some other problems during Install build target (even when Build one was OK), but not sure about that (need first issue to be fixed to make sure).
Created attachment 4698 [details]
Test project to reproduce the issue.
Test project for this issue.
.csproj contains <Import Project="$(SolutionDir)\Test.targets" />
This works fine for Windows solution, but in Monodroid (ProjectTypeGuids defined), I get this error:
error : The imported project "C:\Test.targets" was not found
This is because SolutionDir and SolutionName are undefined when parsing the csproj.
I think it also happens with iOS.
Reopened (added attachment to reproduce the issue easily).
I had a similar issue where the .csproj (Android project) would load fine into VS and it would even Build/Rebuild fine. But when I went to Start Debugging on the project (which involves packaging it) it would fail during the packaging step.
I traced this down to being related to my VersionAssemblyInfo.targets (a small known-good util I use to set the version info of the assembly to my latest git commit hash amongst other things). This targets file was using the $(SolutionDir) property in its script. But for some reason this property was set to a relative path of "..\..\..\..\". Which is technically valid, provided I had prefixed it with the $(ProjectDir) property as well. But doing this would have broken my other projects in the solution which weren't exhibiting this odd behaviour.
In the end I went in search for an equivalent property that had the same effect as SolutionDir but which wasn't broken in this way. I found one called $(MSBuildThisFileDirectory). This worked for me because the VersionAssemblyInfo.targets file was in the root solution folder.
I have the same problem here.
It would be great if it could be fixed.
We really hope this could be fixed before we release our product (otherwise it involves ugly workaround i.e. opening solution through a .bat file to have SolutionName/SolutionDir defined as env. variable).
Note: Probably the only thing you have to do is add SolutionName and SolutionDir to the BuildRequestData you send to the BuildManager.
We changed the way Android deploys to be pure MSBuild based, and that should fix this bug. This is now in alpha. Marking this bug as fixed for verification, please reopen if this is still an issue.
I'm using the latest Xamarin.Android for VS2013.
This issue is still there.
This time, "$(SolutionDir)" will actually show "$(ProjectDir)*Undefined*"