Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error MSB4018: The "ResolveTargetingPackAssets" task failed unexpectedly. #4526

Closed
seunfapps opened this issue Apr 5, 2020 · 8 comments

Comments

@seunfapps
Copy link

I am trying to build a dotnet core project on a linux machine.

Build fails with the following error:
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: The "ResolveTargetingPackAssets" task failed unexpectedly. [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: System.IO.FileNotFoundException: Could not find file '/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/3.0.0/data/FrameworkList.xml'. [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: File name: '/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/3.0.0/data/FrameworkList.xml' [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.Xml.XmlTextReaderImpl.FinishInitUriString() [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at System.Xml.Linq.XDocument.Load(String uri) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj] /usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolveTargetingPackAssets.AddReferencesFromFrameworkList(String frameworkListPath, String targetingPackDllFolder, ITaskItem targetingPack, List1 referenceItems) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolveTargetingPackAssets.ExecuteCore() [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/var/lib/jenkins/workspace/MyProject/MyProject.Shared/MyProject.Shared.csproj]

Build FAILED.

See my csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netcoreapp3.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Dapper" Version="2.0.30" />
        <PackageReference Include="Flurl.Http" Version="2.4.2" />
        <PackageReference Include="Flurl.Http.Xml" Version="1.6.1" />
        <PackageReference Include="LazyCache" Version="2.0.1" />
        <PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
        <PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.0.0" />
        <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.0.0" />
        <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0-rc4" />
        <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0-rc4" />
        <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="5.0.0-rc4" />
        <PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
        <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.5.0" />
        <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.13" />
    </ItemGroup>

    <ItemGroup>
        <Folder Include="Security\" />
    </ItemGroup>

</Project>
@seunfapps
Copy link
Author

Please help.

@safern
Copy link
Member

safern commented Apr 7, 2020

@seunsaber I see you're using 3.0 SDK and targeting netcoreapp3.0 which are out of support. The LTS version is 3.1, I recommend installing the 3.1 SDK and re-targeting your app and see if that still happens there. @dsplaisted might have more insights for the error.

@dsplaisted
Copy link
Member

I think this is an issue we've seen before where the targeting pack was not installed correctly. I think it had something to do with the package dependencies. @wli3 do you remember more?

What is in the following folder? /usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/3.0.0/

If you delete that folder, it may fix the problem.

@wli3
Copy link

wli3 commented Apr 7, 2020

Sorry that doesn't ring a bell

@dagood
Copy link
Member

dagood commented Apr 7, 2020

I think this is an issue we've seen before where the targeting pack was not installed correctly.

Yep, here: #3868. (#3868 (comment)) It's kind of the opposite: the package wasn't uninstalled correctly, so removing the folder is a workaround that lets the SDK download a replacement from nuget.org.

@seunsaber if you can tell us what Linux distro you're using and how you installed .NET Core (package manager?) we can probably confirm you're hitting the same problem.

@seunfapps
Copy link
Author

Hi guys, thanks for the replies. I had to reinstall the SDk. Maybe I did something wrong during the original installation. All is well now, thanks.

@gusennan
Copy link

gusennan commented May 21, 2020

I ran into this same issue. I'm using Fedora 32 and Fedora's dnf package system to update packages. I recently upgraded from Fedora 31 to 32. Deleting the directory

/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/3.1.0

and then rebuilding the project worked.

@Idrisi19
Copy link

i am getting the error Error MSB4018 The "ResolveTargetingPackAssets" task failed unexpectedly. System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.23\data\FrameworkList.xml'.
This is `Microsoft.Net.Sdk.FrameworkReferenceResolution.targets

$(ResolveAssemblyReferencesDependsOn); ResolveTargetingPackAssets;

<!-- Remove Windows SDK KnownFrameworkReference items from BundledVersions.props (they will eventually be removed, but that is in a different repo so
     we can't do the change atomically -->
<ItemGroup>
  <KnownFrameworkReference Remove="Microsoft.Windows.SDK.NET.Ref" />
</ItemGroup>

<!-- Generate KnownFrameworkReference items for the Windows SDK pack -->
<CreateWindowsSdkKnownFrameworkReferences
  UseWindowsSDKPreview="$(UseWindowsSDKPreview)"
  WindowsSdkPackageVersion="$(WindowsSdkPackageVersion)"
  TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
  TargetFrameworkVersion="$(_TargetFrameworkVersionWithoutV)"
  TargetPlatformIdentifier="$(TargetPlatformIdentifier)"
  TargetPlatformVersion="$(TargetPlatformVersion)"
  WindowsSdkSupportedTargetPlatformVersions="@(WindowsSdkSupportedTargetPlatformVersion)">

  <Output TaskParameter="KnownFrameworkReferences" ItemName="KnownFrameworkReference" />

</CreateWindowsSdkKnownFrameworkReferences>

<CheckForDuplicateFrameworkReferences
    FrameworkReferences="@(FrameworkReference)"
    MoreInformationLink="https://aka.ms/sdkimplicitrefs">
  <Output TaskParameter="ItemsToRemove" ItemName="_FrameworkReferenceToRemove" />
  <Output TaskParameter="ItemsToAdd" ItemName="_FrameworkReferenceToAdd" />
</CheckForDuplicateFrameworkReferences>

<ItemGroup>
  <FrameworkReference Remove="@(_FrameworkReferenceToRemove)" />
  <FrameworkReference Include="@(_FrameworkReferenceToAdd)" />
</ItemGroup>

<PropertyGroup>
  <EnableTargetingPackDownload Condition="'$(EnableTargetingPackDownload)' == ''">true</EnableTargetingPackDownload>
  <EnableRuntimePackDownload Condition="'$(EnableRuntimePackDownload)' == ''">true</EnableRuntimePackDownload>
</PropertyGroup>

<PropertyGroup>
  <_NuGetRestoreSupported Condition="('$(Language)' == 'C++' and '$(_EnablePackageReferencesInVCProjects)' != 'true')">false</_NuGetRestoreSupported>
</PropertyGroup>

<ItemGroup>
  <_PackAsToolShimRuntimeIdentifiers Condition="@(_PackAsToolShimRuntimeIdentifiers) ==''" Include="$(PackAsToolShimRuntimeIdentifiers)"/>
</ItemGroup>

<ProcessFrameworkReferences FrameworkReferences="@(FrameworkReference)"
                            KnownFrameworkReferences="@(KnownFrameworkReference)"
                            KnownRuntimePacks="@(KnownRuntimePack)"
                            TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
                            TargetFrameworkVersion="$(_TargetFrameworkVersionWithoutV)"
                            TargetPlatformIdentifier="$(TargetPlatformIdentifier)"
                            TargetPlatformVersion="$(TargetPlatformVersion)"
                            TargetingPackRoot="$(NetCoreTargetingPackRoot)"
                            RuntimeGraphPath="$(RuntimeIdentifierGraphPath)"
                            SelfContained="$(SelfContained)"
                            ReadyToRunEnabled="$(PublishReadyToRun)"
                            ReadyToRunUseCrossgen2="$(PublishReadyToRunUseCrossgen2)"
                            PublishAot="$(PublishAot)"
                            RequiresILLinkPack="$(_RequiresILLinkPack)"
                            IsAotCompatible="$(IsAotCompatible)"
                            EnableAotAnalyzer="$(EnableAotAnalyzer)"
                            PublishTrimmed="$(PublishTrimmed)"
                            IsTrimmable="$(IsTrimmable)"
                            EnableTrimAnalyzer="$(EnableTrimAnalyzer)"
                            EnableSingleFileAnalyzer="$(EnableSingleFileAnalyzer)"
                            AotUseKnownRuntimePackForTarget="$(PublishAotUsingRuntimePack)"
                            RuntimeIdentifier="$(RuntimeIdentifier)"
                            RuntimeIdentifiers="$(RuntimeIdentifiers)"
                            RuntimeFrameworkVersion="$(RuntimeFrameworkVersion)"
                            TargetLatestRuntimePatch="$(TargetLatestRuntimePatch)"
                            TargetLatestRuntimePatchIsDefault="$(_TargetLatestRuntimePatchIsDefault)"
                            EnableTargetingPackDownload="$(EnableTargetingPackDownload)"
                            EnableRuntimePackDownload="$(EnableRuntimePackDownload)"
                            EnableWindowsTargeting="$(EnableWindowsTargeting)"
                            DisableTransitiveFrameworkReferenceDownloads="$(DisableTransitiveFrameworkReferenceDownloads)"
                            KnownCrossgen2Packs="@(KnownCrossgen2Pack)"
                            KnownILCompilerPacks="@(KnownILCompilerPack)"
                            KnownILLinkPacks="@(KnownILLinkPack)"
                            KnownWebAssemblySdkPacks="@(KnownWebAssemblySdkPack)"
                            UsingMicrosoftNETSdkWebAssembly="$(UsingMicrosoftNETSdkWebAssembly)"
                            NETCoreSdkRuntimeIdentifier="$(NETCoreSdkRuntimeIdentifier)"
                            NetCoreRoot="$(NetCoreRoot)"
                            NETCoreSdkVersion="$(NETCoreSdkVersion)">

  <Output TaskParameter="PackagesToDownload" ItemName="_PackageToDownload" />
  <Output TaskParameter="RuntimeFrameworks" ItemName="RuntimeFramework" />
  <Output TaskParameter="TargetingPacks" ItemName="TargetingPack" />
  <Output TaskParameter="RuntimePacks" ItemName="RuntimePack" />
  <Output TaskParameter="Crossgen2Packs" ItemName="Crossgen2Pack" />
  <Output TaskParameter="HostILCompilerPacks" ItemName="HostILCompilerPack" />
  <Output TaskParameter="TargetILCompilerPacks" ItemName="TargetILCompilerPack" />
  <Output TaskParameter="UnavailableRuntimePacks" ItemName="UnavailableRuntimePack" />
  <Output TaskParameter="ImplicitPackageReferences" ItemName="_ImplicitPackageReference" />
  <Output TaskParameter="KnownRuntimeIdentifierPlatforms" ItemName="_KnownRuntimeIdentifierPlatformsForTargetFramework" />

</ProcessFrameworkReferences>

<PropertyGroup Condition="'$(AppHostRuntimeIdentifier)' == '' And
                          ('$(UseAppHost)' == 'true' Or '$(EnableComHosting)' == 'true' Or '$(UseIJWHost)' == 'true')">
  <AppHostRuntimeIdentifier>$(RuntimeIdentifier)</AppHostRuntimeIdentifier>
  <AppHostRuntimeIdentifier Condition="'$(AppHostRuntimeIdentifier)' == ''">$(DefaultAppHostRuntimeIdentifier)</AppHostRuntimeIdentifier>
</PropertyGroup>

<ResolveAppHosts TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
                 TargetFrameworkVersion="$(_TargetFrameworkVersionWithoutV)"
                 TargetingPackRoot="$(NetCoreTargetingPackRoot)"
                 AppHostRuntimeIdentifier="$(AppHostRuntimeIdentifier)"
                 OtherRuntimeIdentifiers="$(RuntimeIdentifiers)"
                 RuntimeFrameworkVersion="$(RuntimeFrameworkVersion)"
                 PackAsToolShimRuntimeIdentifiers="@(_PackAsToolShimRuntimeIdentifiers)"
                 DotNetAppHostExecutableNameWithoutExtension="$(_DotNetAppHostExecutableNameWithoutExtension)"
                 DotNetSingleFileHostExecutableNameWithoutExtension="$(_DotNetSingleFileHostExecutableNameWithoutExtension)"
                 DotNetComHostLibraryNameWithoutExtension="$(_DotNetComHostLibraryNameWithoutExtension)"
                 DotNetIjwHostLibraryNameWithoutExtension="$(_DotNetIjwHostLibraryNameWithoutExtension)"
                 RuntimeGraphPath="$(RuntimeIdentifierGraphPath)"
                 KnownAppHostPacks="@(KnownAppHostPack)"
                 NuGetRestoreSupported="$(_NuGetRestoreSupported)"
                 EnableAppHostPackDownload="$(EnableAppHostPackDownload)"
                 NetCoreTargetingPackRoot="$(NetCoreTargetingPackRoot)">

  <Output TaskParameter="PackagesToDownload" ItemName="_PackageToDownload" />
  <Output TaskParameter="AppHost" ItemName="AppHostPack" />
  <Output TaskParameter="SingleFileHost" ItemName="SingleFileHostPack" />
  <Output TaskParameter="ComHost" ItemName="ComHostPack" />
  <Output TaskParameter="IjwHost" ItemName="IjwHostPack" />
  <Output TaskParameter="PackAsToolShimAppHostPacks" ItemName="PackAsToolShimAppHostPack" />

</ResolveAppHosts>

<PropertyGroup Condition="'$(UsePackageDownload)' == ''">
  <UsePackageDownload Condition="'$(MSBuildRuntimeType)' == 'Core'">true</UsePackageDownload>
  <UsePackageDownload Condition="'$(PackageDownloadSupported)' == 'true'">true</UsePackageDownload>
  <UsePackageDownload Condition="'$(UsePackageDownload)' == ''">false</UsePackageDownload>
</PropertyGroup>

<ItemGroup Condition="'$(UsePackageDownload)' == 'true'">
  <PackageDownload Include="@(_PackageToDownload)">
    <Version>[%(_PackageToDownload.Version)]</Version>
  </PackageDownload>
</ItemGroup>

<ItemGroup Condition="'$(UsePackageDownload)' != 'true'">
  <PackageReference Include="@(_PackageToDownload)"
                    IsImplicitlyDefined="true"
                    PrivateAssets="all"
                    ExcludeAssets="all" />
</ItemGroup>

<!-- Add implicit package references that don't already exist in PackageReference. -->
<ItemGroup>
  <_ImplicitPackageReference Remove="@(PackageReference)" />
  <PackageReference Include="@(_ImplicitPackageReference)"
                    IsImplicitlyDefined="true"
                    PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
  <FrameworkReference Include="@(TransitiveFrameworkReference)" Exclude="@(FrameworkReference)"
                      IsTransitiveFrameworkReference="true" />
</ItemGroup>

<GetPackageDirectory
  Items="@(TargetingPack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedTargetingPack" />

</GetPackageDirectory>

<ItemGroup>
  <ResolvedTargetingPack Condition="'%(ResolvedTargetingPack.Path)' == '' and '%(ResolvedTargetingPack.PackageDirectory)' != ''">
    <Path>%(ResolvedTargetingPack.PackageDirectory)</Path>
  </ResolvedTargetingPack>
</ItemGroup>

<GetPackageDirectory
  Items="@(AppHostPack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedAppHostPack" />

</GetPackageDirectory>

<GetPackageDirectory
  Items="@(SingleFileHostPack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedSingleFileHostPack" />

</GetPackageDirectory>

<GetPackageDirectory
  Items="@(Crossgen2Pack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedCrossgen2Pack" />

</GetPackageDirectory>

<GetPackageDirectory
  Items="@(HostILCompilerPack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedILCompilerPack" />
</GetPackageDirectory>

<GetPackageDirectory
  Items="@(TargetILCompilerPack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedTargetILCompilerPack" />
</GetPackageDirectory>

<GetPackageDirectory
  Items="@(PackAsToolShimAppHostPack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="_ApphostsForShimRuntimeIdentifiersGetPackageDirectory" />

</GetPackageDirectory>

<GetPackageDirectory
  Items="@(ComHostPack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedComHostPack" />

</GetPackageDirectory>

<GetPackageDirectory
 Items="@(IjwHostPack)"
 PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedIjwHostPack" />
</GetPackageDirectory>

<ItemGroup>
  <_ApphostsForShimRuntimeIdentifiers Include="%(_ApphostsForShimRuntimeIdentifiersGetPackageDirectory.PackageDirectory)\%(_ApphostsForShimRuntimeIdentifiersGetPackageDirectory.PathInPackage)" >
    <RuntimeIdentifier>%(_ApphostsForShimRuntimeIdentifiersGetPackageDirectory.RuntimeIdentifier)</RuntimeIdentifier>
  </_ApphostsForShimRuntimeIdentifiers>
</ItemGroup>

<ItemGroup>
  <ResolvedAppHostPack Condition="'%(ResolvedAppHostPack.Path)' == '' and '%(ResolvedAppHostPack.PackageDirectory)' != ''">
    <Path>%(ResolvedAppHostPack.PackageDirectory)\%(ResolvedAppHostPack.PathInPackage)</Path>
  </ResolvedAppHostPack>
</ItemGroup>

<PropertyGroup Condition="'@(ResolvedAppHostPack)' != '' And '$(AppHostSourcePath)' == ''">
  <AppHostSourcePath>@(ResolvedAppHostPack->'%(Path)')</AppHostSourcePath>
</PropertyGroup>

<ItemGroup>
  <ResolvedSingleFileHostPack Condition="'%(ResolvedSingleFileHostPack.Path)' == '' and '%(ResolvedSingleFileHostPack.PackageDirectory)' != ''">
    <Path>%(ResolvedSingleFileHostPack.PackageDirectory)\%(ResolvedSingleFileHostPack.PathInPackage)</Path>
  </ResolvedSingleFileHostPack>
</ItemGroup>

<PropertyGroup Condition="'@(ResolvedSingleFileHostPack)' != '' And '$(SingleFileHostSourcePath)' == ''">
  <SingleFileHostSourcePath>@(ResolvedSingleFileHostPack->'%(Path)')</SingleFileHostSourcePath>
</PropertyGroup>

<ItemGroup>
  <ResolvedComHostPack Condition="'%(ResolvedComHostPack.Path)' == '' and '%(ResolvedComHostPack.PackageDirectory)' != ''">
    <Path>%(ResolvedComHostPack.PackageDirectory)\%(ResolvedComHostPack.PathInPackage)</Path>
  </ResolvedComHostPack>
</ItemGroup>

<PropertyGroup Condition="'@(ResolvedComHostPack)' != '' And '$(ComHostSourcePath)' == ''">
  <ComHostSourcePath>@(ResolvedComHostPack->'%(Path)')</ComHostSourcePath>
</PropertyGroup>

<ItemGroup>
  <ResolvedIjwHostPack Condition="'%(ResolvedIjwHostPack.Path)' == '' and '%(ResolvedIjwHostPack.PackageDirectory)' != ''">
    <Path>%(ResolvedIjwHostPack.PackageDirectory)\%(ResolvedIjwHostPack.PathInPackage)</Path>
  </ResolvedIjwHostPack>
</ItemGroup>

<PropertyGroup Condition="'@(ResolvedIjwHostPack)' != '' And '$(IjwHostSourcePath)' == ''">
  <IjwHostSourcePath>@(ResolvedIjwHostPack->'%(Path)')</IjwHostSourcePath>
</PropertyGroup>

<GetPackageDirectory
  Items="@(RuntimePack)"
  PackageFolders="@(AssetsFilePackageFolder)">

  <Output TaskParameter="Output" ItemName="ResolvedRuntimePack" />

</GetPackageDirectory>

<ResolveFrameworkReferences
  FrameworkReferences="@(FrameworkReference)"
  ResolvedTargetingPacks="@(ResolvedTargetingPack)"
  ResolvedRuntimePacks="@(ResolvedRuntimePack)">

  <Output TaskParameter="ResolvedFrameworkReferences" ItemName="ResolvedFrameworkReference" />

</ResolveFrameworkReferences>

<!-- For design-time builds, don't generate an error if a targeting pack isn't available (ie because it hasn't been restored yet) -->
<PropertyGroup Condition="'$(GenerateErrorForMissingTargetingPacks)' == ''">
  <GenerateErrorForMissingTargetingPacks>true</GenerateErrorForMissingTargetingPacks>
  <GenerateErrorForMissingTargetingPacks Condition="'$(DesignTimeBuild)' == 'true'">false</GenerateErrorForMissingTargetingPacks>
</PropertyGroup>

<ResolveTargetingPackAssets FrameworkReferences="@(FrameworkReference)"
                            ProjectLanguage="$(Language)"
                            ResolvedTargetingPacks="@(ResolvedTargetingPack)"
                            RuntimeFrameworks="@(RuntimeFramework)"
                            GenerateErrorForMissingTargetingPacks="$(GenerateErrorForMissingTargetingPacks)"
                            NuGetRestoreSupported="$(_NuGetRestoreSupported)"
                            DisableTransitiveFrameworkReferenceDownloads="$(DisableTransitiveFrameworkReferenceDownloads)"
                            NetCoreTargetingPackRoot="$(NetCoreTargetingPackRoot)">
  <Output TaskParameter="ReferencesToAdd" ItemName="Reference" />
  <Output TaskParameter="AnalyzersToAdd" ItemName="Analyzer" />
  <Output TaskParameter="PlatformManifests" ItemName="PlatformManifestsFromTargetingPacks" />
  <Output TaskParameter="PackageConflictPreferredPackages" PropertyName="PackageConflictPreferredPackages" />
  <Output TaskParameter="PackageConflictOverrides" ItemName="PackageConflictOverrides" />
  <Output TaskParameter="UsedRuntimeFrameworks" ItemName="_UsedRuntimeFramework" />

</ResolveTargetingPackAssets>

<PropertyGroup>
  <!-- Unescape this semicolon-delimited ordered list so that it's passed as a list to targets
       that consume it. -->
  <PackageConflictPreferredPackages>$([MSBuild]::Unescape($(PackageConflictPreferredPackages)))</PackageConflictPreferredPackages>
</PropertyGroup>

<ItemGroup Condition="'$(RuntimeIdentifier)' == '' or '$(SelfContained)' != 'true'">
  <PackageConflictPlatformManifests Include="@(PlatformManifestsFromTargetingPacks)" />
</ItemGroup>

<ItemGroup>
  <RuntimeFramework Remove="@(RuntimeFramework)" />
  <RuntimeFramework Include="@(_UsedRuntimeFramework)" />
</ItemGroup>





<ItemGroup>
  <Analyzer Remove="@(OffByDefaultAnalyzer)"
            Condition="'%(OffByDefaultAnalyzer.IsEnabled)' != 'true'"
            MatchOnMetadata="FileName" />
</ItemGroup>




<ItemGroup>
  <_ExistingReferenceAssembliesPackageReference Include="@(PackageReference)" Condition="'%(PackageReference.Identity)' == 'Microsoft.NETFramework.ReferenceAssemblies'"/>

  <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="$(MicrosoftNETFrameworkReferenceAssembliesLatestPackageVersion)" IsImplicitlyDefined="true" PrivateAssets="All"
                    Condition="('$(_FullFrameworkReferenceAssemblyPaths)' == '' or $(_FullFrameworkReferenceAssemblyPaths.Contains('microsoft.netframework.referenceassemblies'))) and '@(_ExistingReferenceAssembliesPackageReference)' == ''"/>
</ItemGroup>

<ResolveRuntimePackAssets FrameworkReferences="@(FrameworkReference)"
                          ResolvedRuntimePacks="@(ResolvedRuntimePack)"
                          UnavailableRuntimePacks="@(UnavailableRuntimePack)"
                          SatelliteResourceLanguages="$(SatelliteResourceLanguages)"
                          DesignTimeBuild="$(DesignTimeBuild)"
                          DisableTransitiveFrameworkReferenceDownloads="$(DisableTransitiveFrameworkReferenceDownloads)">
  <Output TaskParameter="RuntimePackAssets" ItemName="RuntimePackAsset" />
</ResolveRuntimePackAssets>

<ItemGroup>
  <ReferenceCopyLocalPaths Include="@(RuntimePackAsset)"
                           Condition="'$(CopyLocalLockFileAssemblies)' == 'true' and ('$(SelfContained)' == 'true' or '%(RuntimePackAsset.RuntimePackAlwaysCopyLocal)' == 'true') and '%(RuntimePackAsset.AssetType)' != 'pgodata'" />
</ItemGroup>

<!--
  If the Microsoft.Extensions.Configuration.UserSecrets package 2.2 or higher is referenced directly,
  it will also add an AssemblyAttribute item. Since this attribute only allows one per assembly, do not
  duplicate the item.

  Also don't add the attribute if there is neither a Microsoft.AspNetCore.App FrameworkReference nor a
  Microsoft.Extensions.Configuration.UserSecrets PackageReference, in order to preserve 2.x SDK behavior
  where projects would successfully build if they define the UserSecretsId property but don't reference
  the corresponding API.

-->
 <ItemGroup Condition=" @(AssemblyAttribute->WithMetadataValue('Identity', 'Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute')->Count()) == 0 And
                        (@(FrameworkReference->WithMetadataValue('Identity', 'Microsoft.AspNetCore.App')->Count()) != 0 Or
                        @(PackageReference->WithMetadataValue('Identity', 'Microsoft.Extensions.Configuration.UserSecrets')->Count()) != 0)">
  <AssemblyAttribute Include="Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute">
    <_Parameter1>$(UserSecretsId.Trim())</_Parameter1>
  </AssemblyAttribute>
</ItemGroup>
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@dsplaisted @gusennan @wli3 @seunfapps @dagood @safern @Idrisi19 and others