There is no option to build solution and open properties of project after retarget to net standard 2.0 - visual-studio-2017

Repro
I created new solution with project targeted net 4.6.1 and its test project.
Project was copied from solution created in VS 2017
I have changed <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
to <TargetFramework>netstandard2.0</TargetFramework> for both unit test and library project (<OutputType>Library</OutputType>).
Now I cannot build solution. When I open project properties window I see error:
An error occurred trying to load the project properties window. Close the window and try again. Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

Answer
I had to replace:
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
to:
<Project Sdk="Microsoft.NET.Sdk">
In my csproj file
Source:
https://arminreiter.com/2017/05/port-net-framework-net-standard/

Does this help?
Ran into the same issue myself. Appears to be an issue with the solution file. I removed the project from the solution then added it back again. This cause VS to recognize this as the correct project type. Hope this helps somebody else from spending too much time on this issue.
Visual studio 2017 not treating csproj as a valid project file after conversion from netstandard to framework

Related

Visual Studio with Qt VS Tools Throws "Object reference not set to an instance of an object" When Opening Qt Project File

Hi I have a hopefully simple issue. When I try to open an existing Qt project file in Visual Studio 2019 by going to Extensions -> Qt VS Tools -> Open Qt Project File then selecting the project I get the error message "Object reference not set to an instance of an object". I have set the Qt version properly I think as in the screenshot. Any idea what might be wrong? There is a bin folder in the Qt install folder which contains qmake.exe and everything else but using that folder doesn't fix anything. One possibly important detail is that the Qt project points to files located on a mapped drive for a network share. Qt Creator opens the project just fine. Thanks!
finally I found the solution:
open the project settings file yourproject.vcxprj with a test editor
find the property group "globals"
<PropertyGroup Label="Globals">
<ProjectGuid>{AAAA-AAA-AAAAA-AAAA}</ProjectGuid>
<Keyword>QtVS_v302</Keyword>
Change the Keyword property to "QtVS_v302" as above.
Open the solution with Visual Studio and now QT Tools should work
In my case keywork was "Qt4VSv1.0" that probably was the setting of an old version of QT Tools that now is obsolete.
I wanted to post this as a comment rather than another answer, but the reputation system blocked me.
Mattia's answer solved the issue for me but I needed to use QtVS_v304 rather than QtVS_v302. It seems that Qt has created another project format.

Missing file NuGet.targets on existing project

The scenario is:
1. Created a NEW solution
2. ENABLED download missing packages
3. Add projects to solution that already exists and depends on nuget packages
4. Building the solution generates an error:
... The missing file is <solution folder>\.nuget\NuGet.targets.
Why? Have missing something?
I'm using Visual Studio 2017 Pro on Windows 10
All my searches answer about the scenario where create a new solution and adds a new project that depends on nuget package, that's ok, but when have an existing project, nothing.
<solution folder>\.nuget\NuGet.targets is a file that NuGet's Visual Studio extension used to add in Visual Studio 2010, 2012 and 2013 when you right click on the solution and select "Enable NuGet Package Restore". It would then add an import in all of your project files to import the targets file. I was recently investigating a customer issue and as part of that investigation I found it made the following changes. Near the top of the csproj, it adds something like this:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
and near the end of the csproj it adds somthing like this:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
So, the problem is that you're creating a new solution, but using existing project files that have been modified in this way. One option is to edit your csrpoj files and remove these changes. Another option is to create new projects, in addition to the new solution, and then copy all your code and content files.
The only disadvantage is if you build on a CI server and use packages.config, your build script needs to run nuget.exe restore, whereas projects that use NuGet.targets could just build the solution and msbuild would execute nuget restore as needed. One advantage of no longer using NuGet.targets is that restoring the whole solution is faster than restoring project by project. Visual Studio automatically restores packages on build, even in VS2010, VS2012 and VS2013, so personally I discourage the use of using this feature, even if you use those old versions of Visual Studio. The benefit of reducing your build script by one step is not worth the issues it brings, in my opinion.

NuGet packages not restore in visual studio 2017

I have Asp.netCore solution which was working fine on Visual Studio 2015 and then i moved to Visual Studio 2017. Now the problem is that in Visual Studio 2017 on every nuget packages there is yellow exclamation mark. Following are solution which i have tried so far.
I'm using Visual Studio Version: 15.3.1
Run as 'Administrator' and restore package.
Clear All Nugget Cache(s) from Tools > options > NuGet Package Manager > and again restore Nuget.
Note: I have searched and found following solution and tried but did not resolve my issue.
Solution 1
I found the answer on another thread here and credit should go to #AxelWass although he did not specifically focus it towards this, it absolutely fixes this issue. The above answer did not.
I had the same issue and solve it by opening the project in a text editor and deleting the following section:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
Once this is removed, it will resolve this nightmare issue that VS2017 and PM seems to be unable to resolve. I too have run into this multiple times - especially when I blend many projects in the same solutions directory.
As mentioned in Microsoft Installing and reinstalling packages with package restore Documentation, you should Update-Package -reinstall:
Update-Package -reinstall -ProjectName <project> command where
is the name of the affected project as it appears in
Solution Explorer. Use Update-Package -reinstall by itself to restore
all packages in the solution.
If you still have the error, try edit your project file, check if there is A path refrence error there, also check the project/solution nuget config file.
By default, new installation of visual studio did not configure package source to search packages online. That caused the problem.
I found the answer with a little bit more work from a stackoverflow link: https://stackoverflow.com/a/32360953/1503372.
That answer mentions to use "https://www.nuget.org/api/v2" url to restore packages. When I opened the package manager console in visual studio 2017, I found it was searching for packages from my PC only (offline search).
I then added "https://www.nuget.org/api/v2" url as a source for restoring packages and it worked.
Follow below steps to add a package source.
Right click project > Manage nuget package and you will see "package source label".
Add highlighted URL to package source.
Select "All" as package source.
Once you have configured your visual studio to search for packages online, your all packages will be restored.
I discovered a wrong configuration in the nuget.config. I don't know why, in this file there are some exclusion for my current project.
You can see your global configuration running this command in File Explorer
%AppData%\NuGet\NuGet.Config

Visual Studio 15 Compilation Fails- clean project

I am using Visual Studio 15 Preview 3
When I create a new project (ASP.Net 5 "Empty" project) and press build all it fails to build. I get the following errors.
Severity Code Description Project File Line Suppression State
Error MSB4063 The "VsTsc" task could not be initialized with its input parameters. WebApplication3 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets 247
Error MSB4064 The "OutputLogFile" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property. WebApplication3 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets 261
Any suggestions please. I have added no code, just created the project and pressed build.
If you check out the Output window contents after the build has failed, it should show the targets file path like this one:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets
Go ahead and remove the OutputLogFile attribute from the VsTsc element. This should make the build go through.
Downgrading "Microsoft.TypeScript.MSBuild" from version 2.0.6 to 1.8.11 removed the Compilation Errors.
I had a similar issue. As it turns out the VsTsc task does support OutputLogFile. When I installed the newer TypeScript nuget packages (Microsoft.TypeScript.Compiler and Microsoft.TypeScript.MSBuild) then it adds Microsoft.TypeScript.targets to the .csproj but neglects to remove the previous lines. Nuget will add lines similar to
<Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.props" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.props')" />
<Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.targets" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.targets')" />
You have to manually removed the two lines pointing to :
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
The same errors were observed after installing Visual Studio Preview. Visual Studio 2015 Community addition Update 3 installed on the same computer also started getting the same errors, on a number of different Typescript solutions. I could build the same solutions on an old computer 'Visual Studio 2015 Community addition Update 1'. I then uninstall Visual Studio Preview. Errors still occurred on Visual Studio 2015 Community addition Update 3. Also then uninstalled and reinstalled community addition and the problem was resolved, and could build the project. I thought this solution may help others with the problem solving a more elegant solution I do not have the reputation points to make a comment (where this belongs).
I was having the same issue with VS2015 Community and downloading the latest version of TypeScript (Version 2.1.5 posted 1/11/17) at https://www.microsoft.com/en-us/download/details.aspx?id=48593 did the trick for me.
I had the same problem. TypeScript tools in VisualStudio 2015 and TypeScript packages attached to project had different versions that is why build failed with "The "VsTsc" task could not be initialized with its input parameters". I reinstalled TypeScript tools for VisualStudio 2015 (get older vertion) it solved my problem.
I had a similar problem.
For me the solution was:
Remove "Microsoft.TypeScript.Compiler" package
Remove "Microsoft.TypeScript.MSBuild" package
from installed packages.

Type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft'

I can see from here, that the namespace Visual Studio should exist within namespace Microsoft, yet I get that error and none of my tests are working!
The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
I am using Visual Studio 2012 with Windows 8.1 (all updated).
I got this error when trying to build a project in TFS. These steps fixed it:
remove reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework
add nuget MSTest.TestFramework
add nuget MSTest.TestAdapter (optional but needed to run tests inside Visual Studio)
The above steps caused this element to be removed from my .csproj file:
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
And these two were added instead:
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
If you're using VS 2017, simply don't put the original project and the test project in the same folder. This will solve the conflict.
The namespace Microsoft.VisualStudio... is defined in assemblies which are not part of the standard Installation of Visual Studio. It is available only if you installed the Visual Studio SDK.
The MSDN Reference to the SDK and included namespaces can be found here.
After installing the SDK add a reference to the required assemblies to your project as described here.
EDIT: Please also check your Visual Studio Version. In the MSDN Link you have posted it says:
You can customize some aspects of Visual Studio Ultimate or Visual Studio Premium to extend existing features or to add new capabilities if you have special requirements. The API reference provides information about the classes to help you with your customization.
If you have one of these Versions, open your unit test project, right click on 'References' -> Choose 'Add Reference' -> Click on 'Assemblies' on the top left and search in the List for 'Microsoft.VisualStudio.TestTools.UnitTesting' (Its either in the 'Framework' or in the 'Extensions' section which you can also choose on the left). You do not need to know the actual location of the dll.
For VS 2017, I had to change the Target Framework in Properties
Ok I found out what the issue was. I had all the solution files in a different place than the usual default.
I had them in a Dropbox folder hoping that I can work on the solution from multiple computers, but apparently that was the cause of the issue.
Moving the whole solution to the default My Documents/VS 2012/Projects/ fixed the problem for me!
In short, if you want things to work smoothly, have the solution files in the usual place, unless you're an advanced user and know what you're doing (I'm not).
I suggest avoid using the "Add reference", it took me some time but I came across this NuGet that has everything that is needed for CodedUITests.
https://www.nuget.org/packages/CodedUIDependencies/1.0.0
Copy Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll somewhere into the root folder of project. When later you will be building test project in console or otherwise, copy it back to debug\bin.
If a project has no reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework I have experienced problems launching tests from Visual Studio UI -> glitches.
I got this error after installing the NuGet Microsoft.JavaScript.UnitTest. After uninstall it worked.
https://www.nuget.org/packages/Microsoft.JavaScript.UnitTest/
In my case, I had an invalid private package source. Because of this, I could not install any package at all (of course). Removing the invalid package source also allowed Visual Studio to install the packages correctly.