Reputation: 664
Pardon the long post. I am trying to give as much info as possible.
I moved some classes from .Net Framework library into a new .Net Standard library in order to reference them from both existing .Net Framework projects and new .Net Core projects. After adding the new .net standard project to the solution that contains the other .Net Framework projects, the existing build definition (XAML) fails to build the .net standard project. It builds fine if i pass /t:restore,build as MSBuild parameters, but this breaks the build for existing .net framework projects in the solution. Visual Studio is able to build the hybrid solution fine. I need to build it in this hybrid solution because the downstream project does the packaging and pushing to our nuget repository (OctopusDeploy).
To overcome this, I have tried to use default targets and initial targets but could not get it to go through.
See the example project below:
<Project InitialTargets="restore" DefaultTargets="publish" Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>MyCompany.Common</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>MyCompany.CommonStandard</AssemblyName>
</PropertyGroup>
</Project>
With the above project file, I get this error. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets (240): There is a circular dependency in the target dependency graph involving target "_FilterRestoreGraphProjectInputItems"
Other things I have tried:
<Project DefaultTargets="restore;build;publish" Sdk="Microsoft.NET.Sdk">
OR
<Project DefaultTargets="restore;publish" Sdk="Microsoft.NET.Sdk">
Error: Bunch of errors stating almost everything is undefined. (vbc: Type 'System.String' is not defined.) Note: passing the same as msbuild targets like /t:restore,build,publish works.
<Project Targets="restore,build,publish" Sdk="Microsoft.NET.Sdk">
OR
<Project DefaultTargets="publish" Sdk="Microsoft.NET.Sdk">
OR
<Project DefaultTargets="publish" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<BuildDependsOn>
Restore;
$(BuildDependsOn);
</BuildDependsOn>
</PropertyGroup>
Error: \obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
<Project InitialTargets="restore" Targets="build,publish" Sdk="Microsoft.NET.Sdk">
OR
<Project InitialTargets="restore" Targets="publish" Sdk="Microsoft.NET.Sdk">
Error: There is a circular dependency in the target dependency graph involving target "_FilterRestoreGraphProjectInputItems".
Thanks for reading. I would really appreciate any guidance in resolving this.
Upvotes: 1
Views: 1155
Reputation: 664
It turned out that my build definitions were pointing to an older version of MSBuild that did not recognize the sdk format. After changing that to MSBuild15 and using the restore,build targets, I was able to get these to work.
Upvotes: 1