Skip to content

Commit

Permalink
Fixing intellisense in vscode for src and ref projects (#34025)
Browse files Browse the repository at this point in the history
* fixing intel for ref and src

* fixing ref and src intell

* renaming props file

* remove extra property

* fixing the intellisense in tests

* add extra line

* addressing feedback

* revert shim path

* fix allconfig restore

* adding comment
  • Loading branch information
Anipik authored Mar 31, 2020
1 parent 8876693 commit 9a14b86
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 81 deletions.
82 changes: 1 addition & 81 deletions src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,75 +50,6 @@
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<BuildSettings Condition="'$(BuildSettings)' == ''">$(BuildTargetFramework)-$(TargetOS)-$(Configuration)-$(TargetArchitecture)</BuildSettings>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFrameworkSuffix)' == 'Windows_NT'">
<PropertyGroup>
<TargetsWindows>true</TargetsWindows>
<PackageTargetRuntime>win</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Unix'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<PackageTargetRuntime>unix</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Linux'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsLinux>true</TargetsLinux>
<PackageTargetRuntime>linux</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Android'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsLinux>true</TargetsLinux>
<TargetsAndroid>true</TargetsAndroid>
<PackageTargetRuntime>android</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'OSX'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsOSX>true</TargetsOSX>
<PackageTargetRuntime>osx</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'iOS'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsiOS>true</TargetsiOS>
<PackageTargetRuntime>ios</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'FreeBSD'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsFreeBSD>true</TargetsFreeBSD>
<PackageTargetRuntime>freebsd</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'NetBSD'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsNetBSD>true</TargetsNetBSD>
<PackageTargetRuntime>netbsd</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'WebAssembly'">
<PropertyGroup>
<TargetsLinux>true</TargetsLinux>
<TargetsWebAssembly>true</TargetsWebAssembly>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == ''">
<PropertyGroup>
<TargetsAnyOS>true</TargetsAnyOS>
</PropertyGroup>
</When>
</Choose>

<!-- Define test projects and companions -->
<PropertyGroup>
Expand Down Expand Up @@ -207,13 +138,6 @@
<PackageRID Condition="'$(PackageRID)' == ''">$(RuntimeOS)-$(TargetArchitecture)</PackageRID>
</PropertyGroup>

<!-- Set some shortcuts for more terse conditions in project files -->
<PropertyGroup>
<TargetsNetCoreApp Condition="$(TargetFramework.StartsWith('netcoreapp'))">true</TargetsNetCoreApp>
<TargetsNetStandard Condition="$(TargetFramework.StartsWith('netstandard'))">true</TargetsNetStandard>
<TargetsNetFx Condition="$(TargetFramework.StartsWith('net4'))">true</TargetsNetFx>
</PropertyGroup>

<!-- set properties for each vertical -->
<PropertyGroup>
<BuildingNETCoreAppVertical Condition="'$(BuildingNETCoreAppVertical)' == '' and ('$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildAllConfigurations)' == 'true')">true</BuildingNETCoreAppVertical>
Expand All @@ -238,6 +162,7 @@

<!-- Import packaging props -->
<Import Project="$(RepositoryEngineeringDir)packaging.props" />
<Import Project="$(MSBuildThisDirectory)targetframework.props" Condition="'$(DesignTimeBuild)' != 'true'" />

<PropertyGroup>
<!-- Always pass portable to override arcade sdk which uses embedded for local builds -->
Expand Down Expand Up @@ -316,9 +241,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<RuntimePath Condition="'$(RuntimePath)' == ''">$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'runtime', '$(BuildSettings)'))</RuntimePath>
<RefRootPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'ref'))</RefRootPath>
<BuildTargetFrameworkRefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', '$(BuildTargetFramework)'))</BuildTargetFrameworkRefPath>
<RefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', '$(TargetFramework)'))</RefPath>
<NetStandard20RefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', 'netstandard2.0'))</NetStandard20RefPath>
<NetStandard21RefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', 'netstandard2.1'))</NetStandard21RefPath>
<NetFxRefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', '$(NetFrameworkCurrent)'))</NetFxRefPath>
Expand Down Expand Up @@ -350,9 +273,6 @@
<!-- setting the output paths -->
<OutputPath>$(BaseOutputPath)$(TargetFramework)-$(TargetFrameworkSuffix)-$(Configuration)\</OutputPath>
<OutputPath Condition="'$(TargetFrameworkSuffix)' == ''">$(BaseOutputPath)$(TargetFramework)-$(Configuration)\</OutputPath>
<BaseIntermediateOutputPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', '$(MSBuildProjectName)'))</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(TargetFramework)-$(TargetFrameworkSuffix)-$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition="'$(TargetFrameworkSuffix)' == ''">$(BaseIntermediateOutputPath)$(TargetFramework)-$(Configuration)\</IntermediateOutputPath>
<AdditionalBuildTargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true' and '$(BuildAllProjects)' == 'true'">$(AdditionalBuildTargetFrameworks);netstandard2.0</AdditionalBuildTargetFrameworks>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<StrongNameKeyId Condition="'$(IsTestProject)' == 'true'">$(TestStrongNameKeyId)</StrongNameKeyId>
</PropertyGroup>

<Import Project="$(MSBuildThisDirectory)intellisense.targets" Condition="'$(DesignTimeBuild)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)resources.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />

Expand Down
80 changes: 80 additions & 0 deletions src/libraries/intellisense.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<Project>
<!-- We are reseting the target framework, so we need to reset the properties derived by the sdk
eg TargetFrameworkIdentifier, TargetFrameworkVersion. In order to do that we are copying the sdk
parsing code https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets#L47
-->
<PropertyGroup>
<_UnsupportedTargetFrameworkError></_UnsupportedTargetFrameworkError>
<TargetFrameworkIdentifier></TargetFrameworkIdentifier>
<TargetFrameworkVersion></TargetFrameworkVersion>
<TargetFrameworkMoniker></TargetFrameworkMoniker>
<NuGetTargetMoniker></NuGetTargetMoniker>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.Contains('-'))">
<_OriginalTargetFramework>$(TargetFramework)</_OriginalTargetFramework>
<TargetFrameworkSuffix>$(TargetFramework.SubString($([MSBuild]::Add($(TargetFramework.IndexOf('-')), 1))))</TargetFrameworkSuffix>
<TargetFramework>$(TargetFramework.SubString(0, $(TargetFramework.IndexOf('-'))))</TargetFramework>
</PropertyGroup>

<!-- Split $(TargetFramework) (e.g. net45) into short identifier and short version (e.g. 'net' and '45'). -->
<PropertyGroup Condition="'$(TargetFramework)' != '' and !$(TargetFramework.Contains(',')) and !$(TargetFramework.Contains('+'))">
<_ShortFrameworkIdentifier>$(TargetFramework.TrimEnd('.0123456789'))</_ShortFrameworkIdentifier>
<_ShortFrameworkVersion>$(TargetFramework.Substring($(_ShortFrameworkIdentifier.Length)))</_ShortFrameworkVersion>
</PropertyGroup>

<!-- Versions with dots are taken as is and just given leading 'v'. -->
<PropertyGroup Condition="'$(TargetFrameworkVersion)' == '' and '$(_ShortFrameworkVersion)' != '' and $(_ShortFrameworkVersion.Contains('.'))">
<TargetFrameworkVersion>v$(_ShortFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>

<!-- Versions with no dots and up to 3 characters get leading 'v' and implicit dots between characters. -->
<PropertyGroup Condition="'$(TargetFrameworkVersion)' == '' and '$(_ShortFrameworkVersion)' != ''">
<TargetFrameworkVersion Condition="$(_ShortFrameworkVersion.Length) == 1">v$(_ShortFrameworkVersion[0]).0</TargetFrameworkVersion>
<TargetFrameworkVersion Condition="$(_ShortFrameworkVersion.Length) == 2">v$(_ShortFrameworkVersion[0]).$(_ShortFrameworkVersion[1])</TargetFrameworkVersion>
<TargetFrameworkVersion Condition="$(_ShortFrameworkVersion.Length) == 3">v$(_ShortFrameworkVersion[0]).$(_ShortFrameworkVersion[1]).$(_ShortFrameworkVersion[2])</TargetFrameworkVersion>
</PropertyGroup>

<!-- Map short name to long name. See earlier comment for example of how to work with identifiers that are not recognized here. -->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == ''">
<TargetFrameworkIdentifier Condition="'$(_ShortFrameworkIdentifier)' == 'netstandard'">.NETStandard</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier Condition="'$(_ShortFrameworkIdentifier)' == 'netcoreapp'">.NETCoreApp</TargetFrameworkIdentifier>

<!-- The meaning of "net" as a short framework name depends on the version. If it's 4.x or less, it means .NETFramework.
If the version is 5.0 or higher, then "net" means .NET 5.0 and on, which is the evolution of .NET Core, and uses
the .NETCoreApp TargetFrameworkIdentifier. -->
<TargetFrameworkIdentifier Condition="'$(_ShortFrameworkIdentifier)' == 'net' And
$([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '5.0'))">.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier Condition="'$(_ShortFrameworkIdentifier)' == 'net' And
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '5.0'))">.NETCoreApp</TargetFrameworkIdentifier>
</PropertyGroup>

<!--
Trigger an error if we're unable to infer the framework identifier and version.
We have to evaluate this here and not in the target because by the time the target runs,
Microsoft.Common.targets will have defaulted to .NETFramework,Version=v4.0
-->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '' or '$(TargetFrameworkVersion)' == ''">
<_UnsupportedTargetFrameworkError>true</_UnsupportedTargetFrameworkError>
</PropertyGroup>

<Import Project="$(MSBuildThisDirectory)targetframework.props" />

<PropertyGroup>
<GeneratedAssemblyInfoFile>$(IntermediateOutputPath)$(MSBuildProjectName).AssemblyInfo$(DefaultLanguageSourceExtension)</GeneratedAssemblyInfoFile>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' != '' and '$(TargetFrameworkVersion)' != ''">
<TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == '' and '$([System.String]::IsNullOrWhitespace($(TargetFrameworkProfile)))' != 'true'">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion),Profile=$(TargetFrameworkProfile)</TargetFrameworkMoniker>
<TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)</TargetFrameworkMoniker>
</PropertyGroup>

<PropertyGroup>
<!-- Note that the assets.cache file has contents that are unique to the current TFM and configuration and therefore cannot
be stored in a shared directory next to the assets.json file -->
<ProjectAssetsCacheFile Condition="'$(ProjectAssetsCacheFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).assets.cache</ProjectAssetsCacheFile>
<ProjectAssetsCacheFile>$([MSBuild]::NormalizePath($(MSBuildProjectDirectory), $(ProjectAssetsCacheFile)))</ProjectAssetsCacheFile>
<NuGetTargetMoniker>$(TargetFrameworkMoniker)</NuGetTargetMoniker>
</PropertyGroup>

</Project>
85 changes: 85 additions & 0 deletions src/libraries/targetframework.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<Project>
<Choose>
<When Condition="'$(TargetFrameworkSuffix)' == 'Windows_NT'">
<PropertyGroup>
<TargetsWindows>true</TargetsWindows>
<PackageTargetRuntime>win</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Unix'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<PackageTargetRuntime>unix</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Linux'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsLinux>true</TargetsLinux>
<PackageTargetRuntime>linux</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Android'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsLinux>true</TargetsLinux>
<TargetsAndroid>true</TargetsAndroid>
<PackageTargetRuntime>android</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'OSX'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsOSX>true</TargetsOSX>
<PackageTargetRuntime>osx</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'iOS'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsiOS>true</TargetsiOS>
<PackageTargetRuntime>ios</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'FreeBSD'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsFreeBSD>true</TargetsFreeBSD>
<PackageTargetRuntime>freebsd</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'NetBSD'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsNetBSD>true</TargetsNetBSD>
<PackageTargetRuntime>netbsd</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'WebAssembly'">
<PropertyGroup>
<TargetsLinux>true</TargetsLinux>
<TargetsWebAssembly>true</TargetsWebAssembly>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == ''">
<PropertyGroup>
<TargetsAnyOS>true</TargetsAnyOS>
</PropertyGroup>
</When>
</Choose>

<PropertyGroup>
<TargetsNetCoreApp Condition="$(TargetFramework.StartsWith('netcoreapp'))">true</TargetsNetCoreApp>
<TargetsNetStandard Condition="$(TargetFramework.StartsWith('netstandard'))">true</TargetsNetStandard>
<TargetsNetFx Condition="$(TargetFramework.StartsWith('net4'))">true</TargetsNetFx>
</PropertyGroup>

<PropertyGroup>
<RefRootPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'ref'))</RefRootPath>
<RefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', '$(TargetFramework)'))</RefPath>
<BaseIntermediateOutputPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', '$(MSBuildProjectName)'))</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(TargetFramework)-$(TargetFrameworkSuffix)-$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition="'$(TargetFrameworkSuffix)' == ''">$(BaseIntermediateOutputPath)$(TargetFramework)-$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>

</Project>

0 comments on commit 9a14b86

Please sign in to comment.