[ Moved from dotnet/cli#4992 ]
test_app.zip
in test_app\App:
dotnet restoredotnet build -r win10-x64build succeeds
build fails with output:
C:\Users\svbomer\AppData\Local\Temp\.NETStandard,Version=v1.4.AssemblyAttributes.cs(4,20): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(6,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(7,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(8,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(9,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(10,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(11,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(12,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(13,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(14,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
C:\Users\svbomer\AppData\Local\Temp\.NETStandard,Version=v1.4.AssemblyAttributes.cs(4,71): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
C:\Users\svbomer\AppData\Local\Temp\.NETStandard,Version=v1.4.AssemblyAttributes.cs(4,100): error CS0246: The type or namespace name 'FrameworkDisplayName' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
C:\Users\svbomer\AppData\Local\Temp\.NETStandard,Version=v1.4.AssemblyAttributes.cs(4,123): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(6,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(7,61): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(8,59): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(9,59): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(10,68): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(11,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(12,53): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(13,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(14,63): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
Library.cs(1,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
C:\Users\svbomer\AppData\Local\Temp\.NETStandard,Version=v1.4.AssemblyAttributes.cs(2,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
C:\Users\svbomer\AppData\Local\Temp\.NETStandard,Version=v1.4.AssemblyAttributes.cs(3,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(3,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
obj\Debug\netstandard1.4\Library.AssemblyInfo.cs(4,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
Library.cs(30,7): error CS0518: Predefined type 'System.Object' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
Library.cs(3,14): error CS0518: Predefined type 'System.Object' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
Library.cs(19,12): error CS0518: Predefined type 'System.Int32' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
Library.cs(24,24): error CS0518: Predefined type 'System.Int32' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
Library.cs(24,12): error CS0518: Predefined type 'System.Void' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]Library.cs(5,13): error CS0518: Predefined type 'System.Int32' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]Library.cs(6,13): error CS0518: Predefined type 'System.Int32' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]Library.cs(8,5): error CS0518: Predefined type 'System.Void' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
Library.cs(14,20): error CS0518: Predefined type 'System.Int32' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
Library.cs(14,5): error CS0518: Predefined type 'System.Void' is not defined or imported [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj] D:\cli\artifacts\win10-x64\stage2\sdk\1.0.0-preview5-004233\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(82,5): error : Assets file 'C:\Users\svbomer\active\projects\managed_linker\test_app\Library\obj\project.assets.json' doesn't have a target for '.NETStandard,Version=v1.4/win10-x64'. Ensure you have restored this project for TargetFramework='netstandard1.4' and RuntimeIdentifier='win10-x64'. [C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj]
D:\cli\artifacts\win10-x64\stage2\sdk\1.0.0-preview5-004233\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(82,5): error : Cannot find project info for 'C:\Users\svbomer\active\projects\managed_linker\test_app\Library\Library.csproj'. This can indicate a missing project reference. [C:\Users\svbomer\active\projects\managed_linker\test_app\App\test_app.csproj]
dotnet --info output:
.NET Command Line Tools (1.0.0-preview5-004233)
Product Information:
Version: 1.0.0-preview5-004233
Commit SHA-1 hash: 1fd99f1588
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: D:\cli\artifacts\win10-x64\stage2\sdk\1.0.0-preview5-004233
Jus repro'd it with csproj files compatible with the new implicit items:
repro.zip
Reproduces with CLI versions 1.0.0-rc4-004598 as well as 1.0.0-rc3-004517. (run dotnet restore and dotnet publish -r win7-x64 in the App directory)
This currently prevents creating self-contained applications that reference a library project.
Is this scenario expected to work in RC3? cc @dsplaisted @nguerrera
Is this the same as https://github.com/dotnet/sdk/issues/527? @nguerrera
I attempted an upgrade to RC3 on my project and ran into this issue. Is a short term fix anticipated or should I roll back until later?
The problem seems to be that when dotnet build -r some-RID sets RuntimeIdentifier, this is also passed along to referenced projects. If a referenced project has not been restored for a runtime (like a library project), this fails with the following error:
…/1.0.0-rc3-004530/…/Microsoft.NET.Sdk.targets(76,5): error :
Assets file '…' doesn't have a target for '.NETStandard,Version=v1.4/win10-x64'.
Ensure you have restored this project for TargetFramework='netstandard1.4' and RuntimeIdentifier='win10-x64'. […/Lib/Lib.csproj]
@AlgorithmsAreCool Since I don't know a simple way to unset properties (is there any?), the only way I could make this work is by using and intermediate property:
Use dotnet build /p:AppRuntimeIdentifier=win10-x64 to build.
In the main application's csproj file:
<PropertyGroup>
<RuntimeIdentifier>$(AppRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>
@srivatsn I don't think this is related to #527
Interesting. @DustinCampbell was talking about this issue as well. I suspect the fix needs to be a mix of CLI and SDK similar to what you've done. The CLI should set /p:RequestedRuntimeIdentifier or some such property and have the SDK apply it to a project only if it's "applicable". We'll need the same thing for -f as well.
@piotrpMSFT @livarcocc thoughts?
Yes, we need to fix this. Per our hallway conversation, we should do the same thing for TargetFramework as well. This becomes a significant problem when trying dotnet build an .sln file.
@rainersigwald
Yes, setting a property at the command line overrides all projects that build in that invocation. Having an EntryPointRuntimeIdentifier or something similar sounds reasonable (albeit as another concept people have to know about).
@rainersigwald: I you recall, this is the thing you and I chatted about last Friday.
I don't think it's actually another concept. From the user perspective, MSBuild will do the thing it's always done. If you set RuntimeIdentifier or TargetFramework globally, it's applied globally. However, from the perspective of the CLI, setting the "--framework" or "--runtime" properties during "dotnet build" can be a bit smarter and do what the user very likely expects to happen.
Yeah, it makes sense once you know the details--but understanding that dotnet build --runtime Whatever is more than just sugar over MSBuild /p:Runtime=Whatever is required. Still think it's the right thing to do.
If we had more time I might recommend renaming the inner per-project property to be a bit more esoteric and renaming the outer "overall requested" property to more closely match the CLI command line param . . . but that's a nit.
So, what I would expect to happen:
For all projects that specify RuntimeIdentifiers, it sets RuntimeIdentifier if not already set.
I guess it would look sth like:
<RuntimeIdentifier Condition=" '$(RuntimeIdentifier)' == '' and '$(EntryPointRuntimeIdentifier)' != '' and '$(RuntimeIdentifiers)' != '' ">$(EntryPointRuntimeIdentifier)</RuntimeIdentifier>
It should be possible to reference RID-specific and RID-agnostic projects that way.
If we had more time I might recommend renaming …
@rainersigwald Since this will (and should) probably stick around for at least a decade or two, I'd like there to be a proper naming strategy ❤️
@srivatsn @piotrpMSFT Since this issue is separate from the other RID issues on my plate and time is of the essence could someone else drive this into CLI + SDK?
@rainersigwald:
Yeah, it makes sense once you know the details--but understanding that dotnet build --runtime Whatever is more than just sugar over MSBuild /p:Runtime=Whatever is required. Still think it's the right thing to do.
That's fair, but people probably shouldn't be thinking of dotnet build as sugar over MSBuild. If that's all it were, there isn't much value from a CLI UI perspective.
I was able to work around my issue with by making the restore -r <RID> step explicit in my build pipeline for now.
@piotrpMSFT has graciously offered to help out with this. Assigning to Peter.
I'm also hitting this when trying to upgrade foundatio: https://github.com/exceptionless/foundatio/tree/feature/dotnet
@niemyjski are you specifying an RID when you build or publish? If so have you tried adding a dotnet restore -r <RID> step just before your build/publish in your build script?
Starting to take a look at this. Per @DustinCampbell's point, we want to address both:
-r for a root project whose P2P dependencies are not RID specific-f or -r for a solution for which only some projects support that TFM or RIDHaving looked at the SDK a bit, I'm less convinced now that the solution to these problems will be unified. This issue may end up being split into two, where we will want to fix both. More info to come.
odd. I just tried @dasMulli's repro on CLI 1.0.0-rc4-004748 on osx with -r osx.10.11-x64 and the publish operation was successful, producing what seems to be a working self contained app. I'll try this again on Windows when in the office tomorrow. Going to lok at -f for now.
@piotrpMSFT really odd.. it repros with both 1.0.0-rc4-004748 and 1.0.0-rc4-004755 on my Mac 😕
Another workaround that works is to reference the library with:
<ProjectReference Include="..\Lib\Lib.csproj" Properties="RuntimeIdentifier=" />
This would be easier to do with an update item from the SDK but I haven't explored what the effects are - probably loosing RID-specific items from projects. (did this ever work in project.json? RID-specific libraries?)
@AlgorithmsAreCool Nope, no rids at all.
Just thought I'd share that PR #828 should address the RID issue and does not introduce any new user gestures or concepts. We were able to keep the alternate property name as an internal contract between Referring projects and Referenced projects.
I'm trying a similar approach with the build sln -f issue... though that is proving considerably more involved.
No, it's not merged yet. I hope to have a CLI that exhibits this behavior available this week, however. Since -r is mostly a command-line consideration, this should unblock most affected folks.
The change impacts a lot of repos, so merging it will be a full-day dance I'm afraid.
Fixed with #836
Most helpful comment
Just thought I'd share that PR #828 should address the RID issue and does not introduce any new user gestures or concepts. We were able to keep the alternate property name as an internal contract between Referring projects and Referenced projects.
I'm trying a similar approach with the
build sln -fissue... though that is proving considerably more involved.