The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.0.0 - asp.net-core-1.1

I am getting this build error after adding assembly reference(xyz.dll) in .Net Core 1.1 console application.
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Here are the details of my ConsoleApp.csproj.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="xyz">
<HintPath>bin\Debug\netcoreapp1.1\xyz.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
I am using Visual Studio Professional 2017 version 15.3.2 .
I have also created console app targeting to .NET 4.5.2, included xyx.dll reference and it worked with no issues.

Related

How can I include the entire build output in a nuget package programatically using GeneratePackageOnBuild

I'm using <GeneratePackageOnBuild>True</GeneratePackageOnBuild> to get Visual Studio to automatically build a Nuget package when I build my project. But this package is being used as a plugin to another project. So I've included <EnableDynamicLoading>True</EnableDynamicLoading>. This causes all of the dependency DLLs to be copied to the build output folder. So far so good.
The problem is that when Visual Studio builds the Nuget package, only the main project dll is included in the package. How do I get Visual Studio to include all of the build output files in the Nuget package?
Here is my project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.2.6</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<EnableDynamicLoading>True</EnableDynamicLoading>
<PackageId>ProjectName</PackageId>
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Package1" Version="3.1.0">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Package2" Version="1.0.1" PrivateAssets="All" />
<PackageReference Include="Package3" Version="1.0.4" PrivateAssets="All" />
</ItemGroup>
</Project>
I want my nuget package to include: ProjectName.dll, Package2.dll, and Package3.dll

tfs 2013 custom checkin policy is not visible

I'm trying to create a custom checkin policy in TFS 2013. Followed this example and I create WorkitemStateControlPolicy class below
https://blog.devart.com/creating-tfs-custom-check-in-policy.html
namespace WIStateControlPolicy
{
[Serializable]
public sealed class WorkitemStateControlPolicy : PolicyBase
{
[NonSerialized]
private IPendingCheckin pendingCheckin;
public const string ClosedStatus = "System.Reason";
........
........
}
}
I build this project, WorkitemStateControl.dll created. Registy key I am using:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0_Config\TeamFoundation\SourceControl\Checkin Policies]
"WorkitemStateControl"="c:\\Users\\me\\Desktop\\dll\\WorkitemStateControl.dll"
Then I checked the visual studio 2015 add checkin policy but new policy is not visible in list
I tried also this registy path:
(HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\TeamFoundation\SourceControl\CheckinPolicies)
But problem not changed.
My queston is, why new checkin policy is not visible? Should I change anything on tfs server?
There is not really a concept of a Check-in policy to go hand-hand with a version of Team Foundation Server. Instead these are plugins for Visual Studio. So you'rn buiding a plugin for that specific version of Visual Studio that happens to connect to a Team Foundation Server.
A such, each version of Visual Studio needs its own versions of the assemblies, compiled against the correct version of .NET and the correct version of the Team Foundation Server Client Object Model that matches the version that ships with the Team Explorer "extension" for Visual Studio.
You then register a different path to the specific assembly containing the policy into each registry tree of the version of Visual Studio you support. Ohh and don't forget to register the x86 and the x64 registry trees :).
Windows Registry Editor Version 5.00
//v12
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\TeamFoundation\SourceControl\Checkin Policies]
"JesseHouwing.CheckinPolicies"="C:\Program Files(x86)\\MyCompany\\Checkin Policies\\v12.0\\JesseHouwing.CheckinPolicies.dll"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\12.0\TeamFoundation\SourceControl\Checkin Policies]
"JesseHouwing.CheckinPolicies"="C:\Program Files(x86)\\MyCompany\\Checkin Policies\\v12.0\\JesseHouwing.CheckinPolicies.dll"
//v14
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\TeamFoundation\SourceControl\Checkin Policies]
"JesseHouwing.CheckinPolicies"="C:\Program Files(x86)\\MyCompany\\Checkin Policies\\v14.0\\JesseHouwing.CheckinPolicies.dll"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0\TeamFoundation\SourceControl\Checkin Policies]
"JesseHouwing.CheckinPolicies"="C:\Program Files(x86)\\MyCompany\\Checkin Policies\\v14.0\\JesseHouwing.CheckinPolicies.dll"
etc...
All the details are in this blog post.
VISUAL STUDIO PROJECT TYPE CPU .NET VERSION TFS OM VERSION VISUAL STUDIO VERSION
2017 Class Library AnyCPU 4.6 15.0.0.0 v15.0
2015 Class Library AnyCPU 4.6 14.0.0.0 v14.0
2013 Class Library AnyCPU 4.5 12.0.0.0 v12.0
2012 Class Library AnyCPU 4.0 11.0.0.0 v11.0
2010 Class Library AnyCPU 4.0 10.0.0.0 v10.0
2008 Class Library AnyCPU 3.0 9.0.0.0 v9.0
2005 Class Library AnyCPU 2.0 8.0.0.0 v8.0
And a sample project that targets multiple Visual Studio Versions.
In this project I've manually tweaked the project files to dynamically reference the version of the Client Object Model depending on the selected Visual Studio version using a choose/when construct:
<Choose>
<When Condition="'$(Configuration)' == 'VS2013'">
<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.VersionControl.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<When Condition="'$(Configuration)' == 'VS2012'">
<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.VersionControl.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<When Condition="'$(Configuration)' == 'VS2010'">
<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.VersionControl.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.VersionControl.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</Otherwise>
</Choose>
You can use similar tricks to reference different NuGet versions for later versions of Team Explorer. The TFS Aggregator project is built against every version of the Client Object Model since 2013 and we dynamically include a targets file to setup the references and nuget dependencies.

How to Add Reference to a netstandard 2.0 Nuget from VS2013 .Net Framework 4.8 Project

I have a vs 2013 project which targets .net framework 4.8. I need to add a reference to Microsoft.Extensions.Hosting nuget package but when I do I get the following error on package manager console.
Error message:
PM> Install-Package Microsoft.Extensions.Hosting -Version 2.2.0
Installing 'Microsoft.Extensions.Hosting 2.2.0'.
You are downloading Microsoft.Extensions.Hosting from Microsoft, the license agreement to which is available at https://raw.githubusercontent.com/aspnet/AspNetCore/2.0.0/LICENSE.txt. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Extensions.Hosting 2.2.0'.
Adding 'Microsoft.Extensions.Hosting 2.2.0' to QuartzExample.
Uninstalling 'Microsoft.Extensions.Hosting 2.2.0'.
Successfully uninstalled 'Microsoft.Extensions.Hosting 2.2.0'.
Install failed. Rolling back...
Install-Package : Could not install package 'Microsoft.Extensions.Hosting 2.2.0'. You are trying to install this package into
a project that targets '.NETFramework,Version=v4.8', but the package does not contain any assembly references or content
files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Microsoft.Extensions.Hosting -Version 2.2.0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
My Project File looks like this
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{07E02FE5-9E9B-434D-B6A2-D037DE7CE6CA}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuartzExample</RootNamespace>
<AssemblyName>QuartzExample</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Quartz, Version=3.0.7.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.3.0.7\lib\net452\Quartz.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Quartz.Jobs, Version=3.0.7.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.Jobs.3.0.7\lib\net452\Quartz.Jobs.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Quartz.Plugins, Version=3.0.7.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
<HintPath>..\packages\Quartz.Plugins.3.0.7\lib\net452\Quartz.Plugins.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MyJob.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="quartz_jobs.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
My App.Config is as follows
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<quartz>
<add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz.Plugins" />
<add key="quartz.plugin.xml.fileNames" value="~/quartz_jobs.xml" />
</quartz>
</configuration>
Without updating Visual Studio 2013, can I add references to a .netstandard2 nuget such as Microsoft.Extensions.Hosting?
You can't. VS2013 has an ancient version of NuGet which doesn't know anything about .NET Standard and therefore can't know that .NET Standard 2.0 is compatible with the .NET Framework 4.8.
If you really can't upgrade to a newer Visual Studio, maybe you can look into .NET Core. Visual Studio Code is a tiny installation and provides good .NET development experience, otherwise any text editor will do, you just lose intellisense if you can't use something that supports Omnisharp.

How to consume a .net4.7 app from .net core 2.0

I have a .net core test app that's referencing a .net framework 4.7.1 project. I've updated the project file of the .net core project so that it looks like this...
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PushNotifications\PushNotifications.csproj" />
</ItemGroup>
</Project>
When I debug a test, I get..
Catastrophic failure: System.TypeInitializationException: The type
initializer for 'Xunit.DiaSession' threw an exception. --->
System.IO.FileNotFoundException: Could not load file or assembly
'System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.
Adding System.Reflection.TypeExtensions to either project has no effect.
What else do I need to do?

Loading VS2015 solution in VS2017, coded UI test references are not found

I opened our solution in Visual Studio 2017 but some testing references aren't found, specifically:
Microsoft.VisualStudio.QualityTools.CodedUITestFramework
Microsoft.VisualStudio.TestTools.UITest.Common
Microsoft.VisualStudio.TestTools.UITesting
Opening under VS2015 they load fine and I can see the references under the Visual Studio 2015 folder structure "Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies\".
However they don't appear under the 2017 installed files: "\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\".
How can I get VS to pick up these references, am I missing a plug-in or extension? Have they been consolidated or deprecated?
Microsoft Visual Studio Enterprise 2017
Version 15.0.26228.4 D15RTWSVC
Microsoft .NET Framework
Version 4.6.01055
If you are running VS 2017 Enterprise then you can use this solution to add Coded UI Test back.
https://stackoverflow.com/a/42788766/2563765
If you want to remove those references in your project because you are not using Coded UI Test anymore, you can
1) Unload your project
2) Edit the .csproj file
3) Find
<IsCodedUITest>True</IsCodedUITest>
<TestProjectType>CodedUITest</TestProjectType>
and repleace with
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
4) Remove
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' Or '$(VisualStudioVersion)' == '11.0'">
<ItemGroup>
<Reference Include="UIAutomationTypes" />
</ItemGroup>
</When>
</Choose>
and
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
if found
5) Reload the project

Resources