runtime: NativeAot publish fail
Description
ConsoleApp1 -> E:\ConsoleApp1\bin\Release\net7.0\win-x64\ConsoleApp1.dll 系统找不到指定的文件。 Generating native code 文件名、目录名或卷标语法不正确。 C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.DotNet.ILCompiler\build\Microsoft.NETCore.Native.targets(350,5): err or MSB3073: 命令““系统找不到指定的文件。;d:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.35.32213\bin\Hostx64 \x64\link.exe” @“obj\Release\net7.0\win-x64\native\link.rsp””已退出,代码为 123。 [E:\ConsoleApp1\ConsoleApp1 .csproj]
Reproduction Steps
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>
dotnet publish -r win-x64 -c Release
Expected behavior
publish success
Actual behavior
publish fail
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24 (24 by maintainers)
Yes, Windows SDK (and number of other components that come with
Desktop development with C++workload) are required. We do not want to be in a business of reshipping or recreating Windows SDK or other parts of Visual Studio.We depend on number of Windows SDK libs, it is not just advapi32.lib: https://github.com/dotnet/runtime/blob/21a8eb51ad181f6eb2d7f24d8eda34840025a8a0/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Windows.targets#L53-L67
Yes, or the accompanying bat file (which runs vswhere command) can also detect it and produce the error? Lets see. I will wait for @jkotas thoughts on Windows SDK requirement.
We switched to vswhere in https://github.com/dotnet/corert/commit/9e2f0159b80f37f8caaf7589febe6172c8b2f8c4. At that time, I had a system which I was restoring to factory settings to create different kinds of undesired states to form error message. IIRC, Windows SDK requirement wasn’t spotted; which could be an oversight or because it is now pulled from cryptography lib object required by one of the runtime libs object. Maybe there is a way to not depend on Windows SDK and still facilitate advapi32.lib dependency. 🤔
Windows SDK installed and work well