Visual Studio .Net Target Framework Version is grayed out - visual-studio

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.

Related

Share files between projects in visual studio 2013?

I have a F# project which is compiled for .Net 4.5. However, I need it to be compiled .Net 4.0 too. I created another project target .Net 4.0 and I can copy all the same files from the .Net 4.5 project to the newly created project.
The project referred some NuGet libraries which have different packages for .Net 4.5 and 4.0 so I cannot simply change the project's .Net version and recompile. How to avoid maintain two copies of the same files? I know VS 2015 has shared files function.
try "Add As Link".
Project menu > Add Existing Item... and in the Add drop-down list, click Add As Link.
I think you would be better off using source control to share files.
The source control has one copy.
Having a multiple copies on your hard drive is actually a good thing. One project can use a stable version while another project updates and tests a new version.
The only disadvantage is if one project checks in changes, you must remember to do a 'get' for the other projects.

Unable to alter PCL library Target Frameworks

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.

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.

How to install a WSP that has dependant assemblies?

I have a solution in Visual Studio 2010 that is made up of 3 projects.
I have one project for my SharePoint 2010 custom timer job, one project (Project A) that is used by my custom timer job, and another project (Project B) that is used by Project A.
The problem is that when I package my project the WSP only installs the Custom Timer Job to the GAC. Is there some way to have all dependant DLLs installed as well?
You have to add those DLLs (project references) manually into the WSP project's manifest. There's a UI in Visual Studio to assist you with this, no need to modify the XML directly.
Steps:
In Solution Explorer within your WSP project locate the Package folder.
Double-click on Package.package file to open the package designer.
In the bottom of the screen click on 'Advanced'; a screen showing 'Additional Assemblies' will open.
Click on 'Add' and select 'Add assembly from Project Output'.
Choose the assembly and deployment mode (GAC or WebApplication = bin folder).
In this dialog you can also register the associated safe controls and resources. Also, via 'Add Existing Assembly' you can add assemblies available in binary form only (i.e. not available as VS projects in source code).

VS2010 add-in to show target framework in solution explorer

Is there a VS2010 add-in that shows a project's target framework version in the Solution Explorer window?
Not exactly in Solution Explorer, but with this plugin you can see and change target frameworks of all your projects in one place.

Resources