Set DisableImplicitNuGetFallbackFolder=false to ensure we never use the NuGet fallback folder that comes with the SDK.

Enable SDK-based projects to import the root dir.props file.  This spawned a few one-off changes since things like the BaseIntermediateOutputPath is now under RepoRoot\Bin and TreatWarningsAsErrors=true.
This commit is contained in:
Eric Erhardt 2017-08-29 17:36:51 -05:00
Родитель 29c18275d5
Коммит ad741e3f76
10 изменённых файлов: 81 добавлений и 36 удалений

28
Directory.Build.props Normal file
Просмотреть файл

@ -0,0 +1,28 @@
<Project>
<PropertyGroup>
<!--
NOTE: This .props file assumes it is only imported by projects that use the SDK="Microsoft.NET.Sdk" in their project.
We are currently on too old of an SDK to detect - it doesn't have https://github.com/dotnet/sdk/pull/1242.
But once we move to a new version, we can remove this property setting, and everything else will work correctly.
-->
<UsingMicrosoftNETSdk>true</UsingMicrosoftNETSdk>
</PropertyGroup>
<PropertyGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'">
<UsingNETSdkCompiler>true</UsingNETSdkCompiler>
<DisableBuildToolsRoslynVersion>true</DisableBuildToolsRoslynVersion>
</PropertyGroup>
<Import Project="dir.props" />
<PropertyGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'">
<!--
The Microsoft.NET.Sdk changed the definition of what it assumes $(BaseIntermediateOutputPath) is.
In the "old" .csproj files, BaseIntermediateOutputPath could be shared with many projects.
In the SDK-based .csproj files, BaseIntermediateOutputPath is assumed to be project-specific.
-->
<BaseIntermediateOutputPath>$(IntermediateOutputPath)</BaseIntermediateOutputPath>
</PropertyGroup>
</Project>

Просмотреть файл

@ -2,6 +2,11 @@
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Condition="Exists('..\dir.props')" Project="..\dir.props" />
<PropertyGroup>
<!-- Directory.Build.props imports this .props file, so ensure it isn't imported again -->
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
</PropertyGroup>
<!-- Define vNext UAP Moniker -->
<PropertyGroup>
<UAPvNextVersion>10.0.15138</UAPvNextVersion>
@ -272,7 +277,7 @@
</PropertyGroup>
<!-- Disable some standard properties for building our projects -->
<PropertyGroup>
<PropertyGroup Condition="'$(UsingNETSdkCompiler)' != 'true'">
<NoStdLib>true</NoStdLib>
<NoExplicitReferenceToStdLib>true</NoExplicitReferenceToStdLib>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
@ -388,7 +393,7 @@
<MicrosoftNetCoreRuntimeAppxOutputPath>$(UWPOutputDir)Microsoft.NET.CoreRuntime.$(MajorVersion).$(MinorVersion).appx</MicrosoftNetCoreRuntimeAppxOutputPath>
</PropertyGroup>
<PropertyGroup>
<PropertyGroup Condition="'$(UsingNETSdkCompiler)' != 'true'">
<!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two properties to any folder that exists to skip
the GenerateReferenceAssemblyPaths task (not target) and to prevent it from outputting a warning (MSB3644). -->
<_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)documentation</_TargetFrameworkDirectories>
@ -400,7 +405,17 @@
<PortableNuGetMode>true</PortableNuGetMode>
</PropertyGroup>
<!-- Use Roslyn Compilers to build -->
<Import Project="$(RoslynPropsFile)" Condition="'$(OsEnvironment)'!='Windows_NT' and Exists('$(RoslynPropsFile)') and '$(UseRoslynCompilers)'!='false'" />
<Import Project="$(RoslynPropsFile)" Condition="'$(OsEnvironment)'=='Windows_NT' and Exists('$(RoslynPropsFile)')" />
<PropertyGroup>
<!--
Never use the NuGet fallback folder that comes with the SDK we use to build.
The NuGet fallback folder can/will contain packages we are building in this repo, and we
want to ensure we use the correct packages.
-->
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
<!-- Use Roslyn Compilers to build, if we are not using the .NET SDK to build -->
<Import Project="$(RoslynPropsFile)" Condition="'$(UsingNETSdkCompiler)' != 'true' and '$(OsEnvironment)'!='Windows_NT' and Exists('$(RoslynPropsFile)') and '$(UseRoslynCompilers)'!='false'" />
<Import Project="$(RoslynPropsFile)" Condition="'$(UsingNETSdkCompiler)' != 'true' and '$(OsEnvironment)'=='Windows_NT' and Exists('$(RoslynPropsFile)')" />
</Project>

Просмотреть файл

@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Don't import props files above this folder since they don't work with the .NET Core SDK. -->
<!--<Import Project="..\dir.props" />-->
<Import Project="$(MSBuildThisFileDirectory)../../RepoDirectories.props" />
<Import Project="$(RepoRoot)BranchInfo.props" />
<PropertyGroup>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
@ -19,17 +15,6 @@
<PackageThirdPartyNoticesFile>$(RepoRoot)THIRD-PARTY-NOTICES.TXT</PackageThirdPartyNoticesFile>
</PropertyGroup>
<!--
Once https://github.com/dotnet/buildtools/issues/1548 is fixed, the following version sections should be simply
<Import Condition="Exists('$(ToolsDir)BuildVersion.targets')" Project="$(ToolsDir)BuildVersion.targets" />
-->
<PropertyGroup>
<TodayTimeStamp>$([System.DateTime]::Now.ToString(yyyyMMdd))</TodayTimeStamp>
<BuildVersionFile Condition="'$(BuildVersionFile)'==''">$(ObjDir)BuildVersion-$(TodayTimeStamp).props</BuildVersionFile>
</PropertyGroup>
<Import Condition="Exists('$(BuildVersionFile)')" Project="$(BuildVersionFile)" />
<PropertyGroup Condition="'$(StabilizePackageVersion)' != 'true'">
<!--
Ensure VersionSuffix is set (especially during 'dotnet restore')

Просмотреть файл

@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dependencies.props))\dependencies.props" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>

Просмотреть файл

@ -3,6 +3,7 @@
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<NoWarn>2008;8021</NoWarn>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -109,7 +109,7 @@
<Target Name="GenerateRuntimeGraph">
<PropertyGroup>
<SharedFrameworkAssetsFile>$(SharedFrameworkSourceRoot)/obj/project.assets.json</SharedFrameworkAssetsFile>
<SharedFrameworkAssetsFile>$(IntermediateOutputRootPath)/framework/project.assets.json</SharedFrameworkAssetsFile>
<SharedFrameworkDepsFile>$(SharedFrameworkNameAndVersionRoot)\$(SharedFrameworkName).deps.json</SharedFrameworkDepsFile>
<RuntimeGraphGeneratorRuntime Condition="'$(OSGroup)'=='Windows_NT'">win</RuntimeGraphGeneratorRuntime>
<RuntimeGraphGeneratorRuntime Condition="'$(OSGroup)'=='OSX'">osx</RuntimeGraphGeneratorRuntime>

Просмотреть файл

@ -26,6 +26,7 @@ namespace LightupClient
catch(FileNotFoundException ex)
{
Console.WriteLine("Exception: Failed to load the lightup assembly!");
Console.WriteLine(ex.ToString());
iRetVal = -1;
}

Просмотреть файл

@ -1,3 +0,0 @@
{
"projects": [ "TestProjects" ]
}

Просмотреть файл

@ -43,7 +43,7 @@ namespace Microsoft.DotNet.CoreSetup.Test
string corehostPackages = null,
string dotnetSdk = null)
{
_repoRoot = repoRoot ?? Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.FullName;
_repoRoot = repoRoot ?? GetRepoRootDirectory();
string baseArtifactsFolder = artifacts ?? Path.Combine(_repoRoot, "Bin");
@ -71,5 +71,27 @@ namespace Microsoft.DotNet.CoreSetup.Test
if(!Directory.Exists(_builtDotnet))
_builtDotnet = builtDotnet ?? Path.Combine(baseArtifactsFolder, "obj", _buildRID+".Release", "sharedFrameworkPublish");
}
private static string GetRepoRootDirectory()
{
string currentDirectory = Directory.GetCurrentDirectory();
while (currentDirectory != null)
{
var gitDirOrFile = Path.Combine(currentDirectory, ".git");
if (Directory.Exists(gitDirOrFile) || File.Exists(gitDirOrFile))
{
break;
}
currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
}
if (currentDirectory == null)
{
throw new Exception("Cannot find the git repository root");
}
return currentDirectory;
}
}
}

Просмотреть файл

@ -143,7 +143,7 @@ namespace Microsoft.DotNet.CoreSetup.Test
sourceTestProject.ProjectName,
testArtifactDirectory);
EnsureGlobalJson(testArtifactDirectory);
EnsureDirectoryBuildProps(testArtifactDirectory);
sourceTestProject.CopyProjectFiles(copiedTestProjectDirectory);
return new TestProject(
@ -153,18 +153,18 @@ namespace Microsoft.DotNet.CoreSetup.Test
sharedLibraryPrefix);
}
private void EnsureGlobalJson(string testArtifactDirectory)
private void EnsureDirectoryBuildProps(string testArtifactDirectory)
{
string globalJsonPath = Path.Combine(testArtifactDirectory, "global.json");
string directoryBuildPropsPath = Path.Combine(testArtifactDirectory, "Directory.Build.props");
Directory.CreateDirectory(testArtifactDirectory);
for(int i = 0; i < 3 && !File.Exists(globalJsonPath); i++)
for(int i = 0; i < 3 && !File.Exists(directoryBuildPropsPath); i++)
{
try
{
// write an empty global.json to ensure that restore doesn't look elsewhere
// for package dependencies to replace with projects.
File.WriteAllText(globalJsonPath, "{}");
// write an empty Directory.Build.props to ensure that msbuild doesn't pick up
// the repo's root Directory.Build.props.
File.WriteAllText(directoryBuildPropsPath, "<Project></Project>");
}
catch (IOException)
{}
@ -286,9 +286,6 @@ namespace Microsoft.DotNet.CoreSetup.Test
storeArgs.Add(outputDirectory);
}
storeArgs.Add("--working-dir");
storeArgs.Add("store_workin_dir");
storeArgs.Add($"/p:MNAVersion={_repoDirectoriesProvider.MicrosoftNETCoreAppVersion}");
dotnet.Store(storeArgs.ToArray())