Unable to alter PCL library Target Frameworks - visual-studio

I am running Visual Studio 2012 plus Xamarin.iOS with the latest version of each. I have Portable Class Libraries in which I want to select the latest "Xamarin.iOS" release as a build target (instead of MonoTouch). In Visual Studio I open up the Project's Properties, select the Library tab, and click on Change under Target Frameworks. However, I am unable to modify any of the checkboxes. Any checkbox I change instantly closes the "Change Target Frameworks" dialog. If I change one of the dropdowns (for example, change from .NET 4.0+ to 4.5) then when I go to click OK the changes do not get reflected in the Target Frameworks list.
Anyone have any idea how to resolve this issue?

I was able to resolve this by changing the TargetFrameworkProfile in the XML of the csproj file. I was on Profile104 which is no longer supported, so I manually removed this and left this blank in the XML, and then was able to re-add the profile targets (after using the dialog it put me on Profile136).

I've encountered a similar problem , while trying to add MvvmCross Nuget Package. I've to change PCL profile to 259 , it didn't allow me ( Xamarin Studio on iOS) , Ok and Cancel buttons are not present.
I opened the .csproj file in TextEditor.
Removed the PCL profile information. Reopened the project.It gave me build error.
So added following string manually
Profile259
It Started working.Hope this information helps.

Related

Visual Studio: Include PlugIn but leave out windows part

I am trying to use not the nuget package but the project itself from the media plugin for xamarin forms.
I am adding all the references and upon build (or even clean) i get :
Error: The specified language targets for uap10.0.16299 is missing. Ensure correct tooling is installed for 'uap'. Missing: '/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Microsoft/WindowsXaml/v16.0/Microsoft.Windows.UI.Xaml.CSharp.targets' (Media.Plugin)
I beleive it is looking for the windows SDK which isnt isntalled on my mac and the project itself only supports android and ios.
Using the nuget package, I can check that I only want ios and Android and it works fine, but upon loading the project in as the project it gives me this error.
In the dependencies folder of the project it is still referencing this UAP 10.0.16299 but upon right click all I can do is "refresh".
How can I build my project and leave out this windows crap?
First include the whole project, then edit the CS proj file (right click on solution -> edit project file).
In the first few lines it says: <TargetFramworks...
Remove the unwanted dependencies. They will be gone in the main folder if you save.
Thats it.

Error publishing an ASP.NET Core 3.1 site to Azure from Visual Studio 2019

I have a preexisting ASP.NET Core 3.0 application which is successfully deployed to an Azure App Service (using the AspNetCoreModuleV2 module). After upgrading the app to (today's release of) ASP.NET Core 3.1, the application builds and runs correctly on my local version of IIS Express. When I attempt to publish to the Azure App Service using (today's release of) Visual Studio 16.4, however, I receive the following error:
Assets file 'C:\Project\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v3.0'. Ensure that restore has run and that you have included 'netcoreapp3.0' in the TargetFrameworks for your project.
Notes
My csproj file's <TargetFramework> is correctly set to netcoreapp3.1.
All <PackageReference>'s to Microsoft.AspNetCore, Microsoft.EntityFrameworkCore, and Microsoft.Extensions have been updated to 3.1.0
I have cleaned my solution, and even nuked my obj folder to ensure there aren't any lingering references.
This error is being generated from the 3.1.100 version of Microsoft.PackageDependencyResolution.targets.
I get that something is still hanging onto the .NET Core 3.0 dependencies. But it's unclear why that's only causing problems during deployment. Is Azure App Service not yet ready for .NET Core 3.1? Or is this an issue with the dependency resolution targets?
The immediate issue—as identified in the original question—has to do with there being two places where <TargetFramework> is set:
The project file (e.g., csproj)
The publishing profile (i.e., pubxml)
The <TargetFramework> must be updated in both locations, and they must match exactly. Otherwise, the publishing won't be able to find its targets in the project.assets.json file, which is built based on the <TargetFramework> in the csjproj file.
Note: You may well expect the pubxml file to defer to the <TargetFramework> set in the csproj file, but that is not the case.
Text Editor
To make this modification via a text editor,
Open the ~/Properties/PublishProfiles folder.
Open the *.pubxml you wish to edit.
Modify the value of <TargetFramework> to netcoreapp3.1:
<TargetFramework>netcoreapp3.1</TargetFramework>
Visual Studio 2019
To make this modification via the Visual Studio 2019 IDE,
Click the gear icon ⚙ on the Web One Click Publish toolbar (it's to the right of the publish icon).
Assuming the Target Framework is not set to netcoreapp3.1, click the edit icon next to it.
Ensure that the Target Framework is set to netcoreapp3.1.
Click Save.
Warning: When using the IDE, you may run into a problem here. When editing the profile you'll likely see the new value from your project file (i.e., netcoreapp3.1) already selected. When you click Save, however, it will revert back to the original value (e.g., netcoreapp3.0 in my case). This is because you didn't actually change the value in the interface, which Visual Studio mistakes for there not being a change to the underlying values. If you temporarily toggle another value (e.g., Configuration), then Visual Studio will recognize that a change has occurred, and both values will be updated in the *.pubxml file.
Acknowledgements
Thank you, again, to #PanagiotisKanavos for pointing me in the right direction (see comments on original thread).
Open Project folder;
Navigate to folder Properties>>PublishProfiles
Open file FolderProfile.pubxml then change version 3.0 to 3.1
netcoreapp3.1
Finally, rebuild your application before publishing
I got this error from a fresh new net5.0 project in VS2019 (ASP.NET Core Web Application template) when using the VS web-publisher. The solution is as follows:
Open file: {project}\Properties\PublishProfiles\{project} - Web Deploy.pubxml
Add the following line inside the <PropertyGroup> element:
<TargetFramework>net5.0</TargetFramework>
The element was missing entirely - great work MS
change
<PackageReferenceInclude="Microsoft.AspNetCore"Version="2.2.0" />
to
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
works for me.

Visual Studio .Net Target Framework Version is grayed out

I am using Visual Studio 2015 to open a C++ CLI project and I want it to target .NET 4.5. My installed .NET version is 4.7. But I cannot edit the project's target framework because it is grayed out.
I have tried to directly edit the project's file in notepad but I couldn't find where the target framework is defined.
Below is part of the screenshot of the .vcxproj file
To complete Hao Peng's answer.
Right click on project.
Select "Unload Project"
Right click on unloaded project.
Select "Edit *.vcxproj"
Modify the "TargetFrameworkVersion" tag from "v4.7" to "v4.5"
Save and close the file
Right click on unloaded project
Select "Reload Project"
This feels a bit hacky; nevertheless, it worked for me. I moved from 4.5.2 to 4.5. YMMV.
In Visual Studio, in Solution Explorer, select your project. On the menu bar, open the Project menu and choose Unload project. This unloads the project (.vcxproj) file for your project.
In my case, I had this issue, while doing migration from .netframework to .net core.
I have multiple projects in my solution, of which base project was created with output type as Class Library and Target framework is set to '.net5.0-windows' by a tool and the other projects are created as '.netstandard 2.0'. Though the dependent projects are configured correctly in .csproj, the option in the properties is grayed out.
However, when I changed base project targetframework to '.netstandard 2.0' then the Target framework has all installed '.netstandard' versions for rest of the projects.

"Project->Project Options" is disabled/greyed out in Xamarin

I'm on Xamarin Studio 6.0.2 (Build 73), running on Windows. Even when I create a fresh new project, the Project Options menu entry is disabled, which means I have to edit the .csproj file in Notepad++, which is not very convenient.
Some other menu entries are also greyed out. As I said, this happens even for New projects created by Xamarin Studio.
So having looked at your version information it seems like Xamarin.Android is not installed which is why you are having this issue.
You will need to install the Xamarin.VisualStudio package. Even if you only intend to use Xamarin Studio, this is required as it includes both Xamarin.Android and Xamarin.iOS.
Please reach out to contact#xamarin.com and we can provide you with the link for this! Please add the link to this question in your email.

Configuration With Same Name Already Exists

I have a solution with 10+ projects (VS2010 SP1). I have the following configurations defined in the solution:
Debug
Debug-QA
Release-UAT
Release-Production
This allows me to easily setup specific settings for each deployment scenario. However, for some reason I can't get things setup as I'd like. Please see this screenshot:
Notice the highlighted projects/configurations. I am unable to create a "Debug-QA" configuration for these projects (by selecting <New> in the cell for that particular project). When I try to add a new "Debug-QA" configuration to the DataUtility project, for instance, Visual Studio yells at me:
This configuration could not be created because a solution configuration of the same name already exists.
I know it does! I'm trying to add the configuration to the project! What am I missing here? I want all projects to have all 5 configuration. I have the same problem when trying to match up (create) platforms (for instance, adding an "Any CPU" platform to the DataUtility project).
Make sure you're using the drop down list from the grid (not the one at the top of the dialog), and do not check the "Create new solution configurations" checkbox when adding your new project configuration.
Here's a workaround if already checked the Create new solution configurations checkbox:
Open Explorer and navigate to the location of the solution for the project that is missing platforms.
Move the solution .sln file to a temorary location where Visual Studio won't locate it.
Open the .csproj file for the project that is missing platforms.
Click the Solutions Platform dropdown.
Click Configuration Manager...
In the table, Click the dropdown in the Platform column for the project and select , to add a new platform.
Click OK.
Repeat adding new platforms as needed.
Save the project.
Return the previously moved solution file back to where it was.
Reopen the combined project solution.
source: https://developercommunity.visualstudio.com/content/problem/972/adding-a-platform-when-one-with-the-same-name-alre.html
The above solution didn't quite work, but I did find a solution on a forum that worked. Described below is to set the builds to x64 for each project that was set to "Any CPU", but the steps would also work for x86.
Open the main solution. Unload each project with a conflict (not
remove).
Leave the solution open.
In Explorer, navigate to the
project folders and open the csproj file in Visual Studio.
In this
screwed up project, navigate to Build->Configuration Manager.
If
needed, "Add New" and set it to x64 and save.
Right-click the
project and set the build architecture to the new x64.
Save this,
but when you close the project in VS, do not save to the solution.
That's unnecessary.
Repeat for each project with a misaligned architecture.
Finally, in the original solution with all the offending projects,
reload each project.
Open the Build->Configuration Manager for the solution. Then, one by
one, reset "Any CPU" to the desired platform, in my case x64.
Save the changes for the solution and rebuild all. You should be OK,
now.

Resources