Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load Xamarin Project... #4

Open
drarsalan opened this issue May 25, 2018 · 2 comments
Open

Unable to load Xamarin Project... #4

drarsalan opened this issue May 25, 2018 · 2 comments
Milestone

Comments

@drarsalan
Copy link

drarsalan commented May 25, 2018

I am trying to load a solution which has xamarin project. I get the following exception.

Microsoft.Build.Exceptions.InvalidProjectFileException : The attribute "Version" in element <PackageReference> is unrecognized.  MyProject.Android.csproj
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Internal.ProjectXmlUtilities.ThrowProjectInvalidAttribute(XmlAttributeWithLocation attribute)
   at Microsoft.Build.Internal.ProjectXmlUtilities.VerifyThrowProjectAttributes(XmlElementWithLocation element, String[] validAttributes)
   at Microsoft.Build.Construction.ProjectParser.ParseProjectItemElement(XmlElementWithLocation element, ProjectItemGroupElement parent)
   at Microsoft.Build.Construction.ProjectParser.ParseProjectItemGroupElement(XmlElementWithLocation element, ProjectElementContainer parent)
   at Microsoft.Build.Construction.ProjectParser.ParseProjectRootElementChildren(XmlElementWithLocation element)
   at Microsoft.Build.Construction.ProjectParser.Parse()
   at Microsoft.Build.Construction.ProjectParser.Parse(XmlDocumentWithLocation document, ProjectRootElement projectRootElement)
   at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext)
   at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ILoggingService loggingService, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext)
   at Microsoft.Build.Construction.ProjectRootElement.<>c__DisplayClass169_0.<OpenProjectOrSolution>b__0(String path, ProjectRootElementCache cache)
   at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded)
   at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ILoggingService loggingService, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, Boolean isExplicitlyLoaded)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectCollection projectCollection)
   at net.r_eg.MvsSln.Core.IsolatedEnv.Load(String path, IDictionary`2 properties) in D:\My Documents\Projects\MvsSln\MvsSln\Core\IsolatedEnv.cs:line 335
   at net.r_eg.MvsSln.Core.IsolatedEnv.Load(ProjectItem pItem, IDictionary`2 properties) in D:\My Documents\Projects\MvsSln\MvsSln\Core\IsolatedEnv.cs:line 323
   at net.r_eg.MvsSln.Core.IsolatedEnv.GetOrLoadProject(ProjectItem pItem, IDictionary`2 properties) in D:\My Documents\Projects\MvsSln\MvsSln\Core\IsolatedEnv.cs:line 209
   at net.r_eg.MvsSln.Core.IsolatedEnv.GetOrLoadProject(ProjectItem pItem, IConfPlatform cfg) in D:\My Documents\Projects\MvsSln\MvsSln\Core\IsolatedEnv.cs:line 170
   at net.r_eg.MvsSln.Core.IsolatedEnv.Load(IEnumerable`1 pItems) in D:\My Documents\Projects\MvsSln\MvsSln\Core\IsolatedEnv.cs:line 312
   at net.r_eg.MvsSln.Core.IsolatedEnv.LoadProjects(IEnumerable`1 pItems) in D:\My Documents\Projects\MvsSln\MvsSln\Core\IsolatedEnv.cs:line 266
   at net.r_eg.MvsSln.Core.SlnParser.Parse(StreamReader reader, SlnItems type) in D:\My Documents\Projects\MvsSln\MvsSln\Core\SlnParser.cs:line 151
   at net.r_eg.MvsSln.Core.SlnParser.Parse(String sln, SlnItems type) in D:\My Documents\Projects\MvsSln\MvsSln\Core\SlnParser.cs:line 103
   at net.r_eg.MvsSln.Sln..ctor(String file, SlnItems type) in D:\My Documents\Projects\MvsSln\MvsSln\Sln.cs:line 54

The project file has the following information.

  <ItemGroup>
    <PackageReference Include="Xamarin.Forms" Version="2.5.0.122203" />
    <PackageReference Include="Xamarin.Android.Support.Design" Version="25.4.0.2" />
    <PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="25.4.0.2" />
    <PackageReference Include="Xamarin.Android.Support.v4" Version="25.4.0.2" />
    <PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="25.4.0.2" />
    <PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="25.4.0.2" />
    <PackageReference Include="Microsoft.Azure.Mobile.Client" Version="4.0.1" />
    <PackageReference Include="Microsoft.Azure.Mobile.Client.SQLiteStore" Version="4.0.1" />
  </ItemGroup>

@3F
Copy link
Owner

3F commented May 30, 2018

Thanks for the report, @drarsalan

The attribute "Version" in element is unrecognized.

More like because of unrelated schema.

Can you also attach this project file (.csproj etc) ?
Seems problem again with backward compatibility exactly in MS internal logic as for #2

Temporarily, you can try to override IsolatedEnv.Load with own logic

protected virtual Project Load(string path, IDictionary<string, string> properties)

Like we use this also in DllExport project to avoid some related problems:

@3F
Copy link
Owner

3F commented Aug 4, 2018

@drarsalan #5 (comment) solves problem via other version of Microsoft.Build.dll. Check this out.

(.netfx 4.6+ for today)

@3F 3F mentioned this issue Oct 15, 2019
@3F 3F added this to the 3.0 milestone Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants