corert icon indicating copy to clipboard operation
corert copied to clipboard

error : The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative

Open 13xforever opened this issue 7 years ago • 15 comments
trafficstars

I followed the examples, but when I try to $ dotnet publish -c Release, I always get this error.

~\.nuget\packages\microsoft.dotnet.ilcompiler\1.0.0-alpha-26125-01\build\Microsoft.NETCore.Native.Publish.targets(54,5): error : The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative [my.csproj]

All I can find is issue #4913, but I can't figure out what I must do with my csproj.

Repro: https://github.com/13xforever/bing-wallpaper/tree/dotnet (note the branch, it's a separate tree in the repo).

13xforever avatar Jan 25 '18 12:01 13xforever

This error happens when you do not specify -r win-x64 argument for publish. The CoreRT publish task requires the target runtime to be specified - either on the command line or in the .csproj file. @13xforever Could you please try again with this argument?

We should get a better error message for this. @A-And Could you please take a look when you get a chance?

jkotas avatar Jan 25 '18 13:01 jkotas

Right, I tried with win10-x64 and it failed with the same error, so I didn't think to try with generic win-x64.

The good news is that with win-x64 or with linux-x64 it does proceed to generating the native code (but fails because of the linking issues).

On Windows $ dotnet publish -c Release -r win-x64 in x64 Native Tools Command Prompt does work. On Linux $ dotnet publish -c Release -r linux-x64 /p:CppCompilerAndLinker=clang does work. (For some reason clang-3.9 is hard-coded for Linux).

Still, there's an issue with all the other non-generic (non-portable) supported runtime ids.

13xforever avatar Jan 25 '18 13:01 13xforever

#5364 is adding error message for the missing rid. There is still an issue with the other specific rids like win10-x64. Ideally, they would be remapped to less specific rid like win-x64 where possible.

jkotas avatar Feb 08 '18 17:02 jkotas

I am also getting this error message but using rid win-x64 doesn't fix it, I still get same error.

Here is my proj file:

<Project>
  <Import Project="$(MSBuildSDKsPath)\Microsoft.NET.Sdk\Sdk\Sdk.props" />
  
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  
  <ItemGroup>
    <PackageReference Include="AngleSharp" Version="0.9.9.2" />
    <PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.1" />
    <PackageReference Include="ShellProgressBar" Version="4.0.0" />
  </ItemGroup>

  <ItemGroup>
    <None Update="config.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>

  <Import Project="$(MSBuildSDKsPath)\Microsoft.NET.Sdk\Sdk\Sdk.targets" />
  
  <Import Project="E:\Projects\corert\bin\Windows_NT.x64.Debug\build\Microsoft.NETCore.Native.targets" />

</Project>

What can I do?

GuerrillaCoder avatar Apr 22 '18 19:04 GuerrillaCoder

I am also getting this error message but using rid win-x64 doesn't fix it, I still get same error.

Did you set the IlcPath property? I see your project doesn't use it and hardcodes the path to Microsoft.NETCore.Native.targets. The property is also used elsewhere.

MichalStrehovsky avatar Apr 23 '18 15:04 MichalStrehovsky

Also, we are publishing packages now. Unless you have a need for building CoreRT yourself from source, it is much easier to use the packages: https://github.com/dotnet/corert/tree/master/samples/HelloWorld

jkotas avatar Apr 23 '18 16:04 jkotas

Is there any way to create on mac? This error is happening when I try dotnet publish -c Release -r osx.10.11-x64 @jkotas @MichalStrehovsky

Jonatthu avatar Jan 17 '19 19:01 Jonatthu

Can you try with dotnet publish -c Release -r osx-x64? That's the RID used in the readme of the HelloWorld sample referenced above.

MichalStrehovsky avatar Jan 17 '19 20:01 MichalStrehovsky

I have same issue when publishing for win7-x64, to fix I have added conditions to csproj.

Issue:

C:\hostedtoolcache\windows\dncs\3.0.100-preview4-011223\x64\sdk\3.0.100-preview4-011223\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [d:\a\1\s\src\Draw2D\Draw2D.csproj]
  Draw2D -> d:\a\1\s\src\Draw2D\bin\Debug\netcoreapp3.0\win7-x64\Draw2D.dll
C:\Users\VssAdministrator\.nuget\packages\microsoft.dotnet.ilcompiler\1.0.0-alpha-27624-01\build\Microsoft.NETCore.Native.Publish.targets(79,5): error : The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative [d:\a\1\s\src\Draw2D\Draw2D.csproj]

Temporary fix:

  <ItemGroup Condition="'$(RuntimeIdentifier)' == 'win-x64' or '$(RuntimeIdentifier)' == 'linux-x64' or '$(RuntimeIdentifier)' == 'osx-x64'">
    <RdXmlFile Include="Draw2D.rd.xml" />
    <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
  </ItemGroup>

wieslawsoltes avatar Apr 24 '19 07:04 wieslawsoltes

publishing for win7-x64

This should be win-x64.

MichalStrehovsky avatar Apr 24 '19 07:04 MichalStrehovsky

publishing for win7-x64

This should be win-x64.

That is correct, but I also publish for non CoreRT builds like win7-x64.

wieslawsoltes avatar Apr 24 '19 07:04 wieslawsoltes

I used the command:

dotnet publish BVLocalSync.csproj -c Release -r win10-x64

It gets an error as follows:

.nuget\packages\microsoft.dotnet.ilcompiler\1.0.0-alpha-27931-02\build\Microsoft.NETCore.Native.Publish.targets(79,5): error : The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative [BVLocalSync.csproj]

Project file is:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="CommandLineParser" Version="2.6.0" />
    <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
    <PackageReference Include="Serilog.Sinks.AwsCloudWatch" Version="4.0.155" />
    <PackageReference Include="System.Management.Automation" Version="6.2.2" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\BVData\BVData.csproj" />
  </ItemGroup>
</Project>

Is win10-x64 still an issue?

genifycom avatar Aug 01 '19 00:08 genifycom

Is win10-x64 still an issue?

Yes - on Windows, we only publish the compiler for the win-x64 RID.

MichalStrehovsky avatar Aug 01 '19 07:08 MichalStrehovsky

Do you know if win10-x64 will be supported for AOT and single exe under DotNet Core 3.0?

Is there a significant different between win10-x64 and win-x64?

genifycom avatar Aug 01 '19 14:08 genifycom

I noticed a feature. If you enter dotnet publish -c release -r win10-x64 (configuration goes first) it will cause an error. But if you enter dotnet publish -r win-x64 -c release (runtime identifier first) it will compile

HappyBullying avatar Jan 24 '20 02:01 HappyBullying