Update build script, re-map VS versions

Extensions should never reference a newer target framework than net46
in VS2017, as documented in https://github.com/github/VisualStudio/issues/1849#issuecomment-411570902.

Therefore, we redesigned the mapping so it's now:

| TargetFramework | Visual Studio |
|-------|------|
| net45 | 2013 |
| net452| 2015 |
| net46 | 2017 |
| net47 | 2019 |

Switch to using Microsoft.Build.Locator instead of hacking MSBuild to
force it to resolve properly. We now run the tests against the same
MSBuild that built the tests.
This commit is contained in:
Daniel Cazzulino 2018-08-22 16:08:29 -03:00
Родитель 0c649bc966
Коммит 1b86784def
22 изменённых файлов: 217 добавлений и 377 удалений

137
build.cmd
Просмотреть файл

@ -1,137 +0,0 @@
@echo off
setlocal enabledelayedexpansion
set BatchFile=%0
set Root=%~dp0
set NodeReuse=true
set MultiProcessor=/m
set BuildConfiguration=Release
set MSBuildTarget=/t:All
set MSBuildAdditionalArguments=
REM Turn on MSBuild async logging to speed up builds
set MSBUILDLOGASYNC=1
set MSBUILDDISABLENODEREUSE=1
:ParseArguments
if "%1" == "" goto :DoneParsing
if /I "%1" == "/?" call :Usage && exit /b 1
if /I "%1" == "/debug" set BuildConfiguration=Debug&&shift&& goto :ParseArguments
if /I "%1" == "/release" set BuildConfiguration=Release&&shift&& goto :ParseArguments
if /I "%1" == "/all" set MSBuildTarget=/t:All&&shift&& goto :ParseArguments
if /I "%1" == "/build" set MSBuildTarget=/t:Build&&shift&& goto :ParseArguments
if /I "%1" == "/clean" set MSBuildTarget=/t:Clean&&shift&& goto :ParseArguments
if /I "%1" == "/rebuild" set MSBuildTarget=/t:Rebuild&&shift&& goto :ParseArguments
if /I "%1" == "/restore" set MSBuildTarget=/t:Restore&&shift&& goto :ParseArguments
if /I "%1" == "/test" set MSBuildTarget=/t:Test&&shift&& goto :ParseArguments
if /I "%1" == "/acceptance" set MSBuildTarget=/t:Acceptance&&shift&& goto :ParseArguments
if /I "%1" == "/update" set MSBuildTarget=/t:Update&&shift&& goto :ParseArguments
if /I "%1" == "/no-node-reuse" set NodeReuse=false&&shift&& goto :ParseArguments
if /I "%1" == "/no-multi-proc" set MultiProcessor=&&shift&& goto :ParseArguments
set MSBuildAdditionalArguments=%1 %MSBuildAdditionalArguments%&&shift&& goto :ParseArguments
:DoneParsing
:: Detect if MSBuild is in the path
for /f "delims=" %%i in ('where msbuild') do set "MSBuildPath=%%i" & goto :MSBuildPathDone
:MSBuildPathDone
if not exist "%MSBuildPath%" (
call :PrintColor Red "To build this repository, MSBuild.exe must be in the PATH."
echo MSBuild is included with Visual Studio 2017 or later.
echo.
echo If Visual Studio is not installed, visit this page to download:
echo.
echo https://www.visualstudio.com/vs/
echo.
exit /b 1
)
:: Detect MSBuild version >= 15
for /f "delims=" %%i in ('msbuild -nologo -version') do set MSBuildFullVersion=%%i
for /f "delims=. tokens=1" %%a in ("%MSBuildFullVersion%") do (
set MSBuildMajorVersion=%%a
)
if %MSBuildMajorVersion% LSS 15 (
call :PrintColor Red "To build this repository, the MSBuild.exe in the PATH needs to be 15.0 or higher."
echo MSBuild 15.0 is included with Visual Studio 2017 or later.
echo.
echo If Visual Studio is not installed, visit this page to download:
echo.
echo https://www.visualstudio.com/vs/
echo.
echo Located MSBuild in the PATH was "%MSBuildPath%".
exit /b 1
)
:: Ensure developer command prompt variables are set
if "%VisualStudioVersion%" == "" (
for /f "delims=" %%i in ('msbuild -nologo %Root%build\corebuild.targets /t:GetVsInstallRoot /v:minimal') do set "VsInstallRoot=%%i" & goto :VsInstallRootDone
:VsInstallRootDone
for /f "tokens=* delims= " %%i in ("%VsInstallRoot%") do set "VsInstallRoot=%%i"
set "DeveloperCommandPrompt=%VsInstallRoot%\Common7\Tools\VsDevCmd.bat"
if not exist "%DeveloperCommandPrompt%" (
call :PrintColor Red "Failed to locate 'Common7\Tools\VsDevCmd.bat' under the reported Visual Studio installation root '%VsInstallRoot%'."
echo.
echo If Visual Studio is not installed, visit this page to download:
echo.
echo https://www.visualstudio.com/vs/
echo.
exit /b 1
)
call "%DeveloperCommandPrompt%" || goto :BuildFailed
)
:: We pass the bare target name as /p:target so that build script can condition behavior accordingly, if necessary
set MSBuildTargetName=%MSBuildTarget:~3%
taskkill /f /im MSBuild.exe /fi "memusage gt 40" >NUL
@echo on
msbuild "%Root%build.proj" /nologo /nr:%NodeReuse% %MultiProcessor% %MSBuildTarget% /p:target=%MSBuildTargetName% /p:Configuration=%BuildConfiguration% /p:NuGetBuildTasksPackTargets=NO-SDK-PACK %MSBuildAdditionalArguments%
@echo off
if ERRORLEVEL 1 (
taskkill /f /im MSBuild.exe /fi "memusage gt 40" >NUL
echo.
call :PrintColor Red "Build failed, for full log see msbuild.log."
exit /b 1
)
taskkill /f /im MSBuild.exe /fi "memusage gt 40" >NUL
echo.
call :PrintColor Cyan "Build completed successfully, for full log see msbuild.log"
exit /b 0
:Usage
echo Usage: %BatchFile% [/all^|/build^|/clean^|/rebuild^|/restore^|/test^|/acceptance^|/update^] [/debug^|/release] [/no-node-reuse] [/no-multi-proc] [OPTIONS]
echo.
echo Build targets:
echo /all Runs clean, restore, build and test
echo /build Runs build
echo /clean Cleans bin,obj,.vs folders.
echo /rebuild Runs clean, restore, then build
echo /restore Restore NuGet packages
echo /test Runs the unit tests
echo /acceptance Runs the (long-running) acceptance tests
echo /update Updates corebuild (build script itself) dependencies
echo.
echo Build options:
echo /debug Perform debug build (/p:Configuration=Debug)
echo /release Perform release build (/p:Configuration=Release). Default.
echo /no-node-reuse Prevents MSBuild from reusing existing MSBuild instances,
echo useful for avoiding unexpected behavior on build machines ('/nr:false' switch)
echo /no-multi-proc No multi-proc build, useful for diagnosing build logs (no '/m' switch)
echo /noautoresponse Do not process the msbuild.rsp response file options
echo
echo [OPTIONS] Arbitrary MSBuild switches can also be passed in.
goto :eof
:BuildFailed
call :PrintColor Red "Build failed with ERRORLEVEL %ERRORLEVEL%"
exit /b 1
:PrintColor
"%Windir%\System32\WindowsPowerShell\v1.0\Powershell.exe" -noprofile write-host -foregroundcolor %1 "'%2'"

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

@ -1,5 +1,4 @@
<Project DefaultTargets="Build" TreatAsLocalProperty="Configuration">
<Import Project="build\corebuild.props" />
<Project Sdk="CoreBuild/1.0.0-alpha" DefaultTargets="Build" TreatAsLocalProperty="Configuration">
<Import Project="src\Directory.Build.props"/>
<PropertyGroup>
@ -16,9 +15,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
<PackageReference Include="Sleet.Azure" Version="*" />
<PackageReference Include="JsonPoke.MSBuild" Version="*" />
<PackageReference Include="xunit.runner.console" Version="2.4.0" />
<PackageReference Include="Sleet.Azure" Version="0.2.5" />
<PackageReference Include="JsonPoke.MSBuild" Version="1.0.9" />
</ItemGroup>
<ItemDefinitionGroup>
@ -31,15 +30,14 @@
<Solution Include="src\*.sln" />
</ItemGroup>
<Target Name="Configure" DependsOnTargets="Restore" />
<Target Name="Build" DependsOnTargets="Version">
<Message Text="##vso[build.updatebuildnumber]$(PackageVersion)" Importance="high" Condition="'$(TF_BUILD)' == 'true'" />
<MakeDir Directories="$(Out)" Condition="!Exists('$(Out)')" />
<MSBuild Projects="@(Solution)" Targets="Build" />
<!-- Also build the tests for Dev14 (by default it's only compiled for dev15) -->
<MSBuild Projects="test\Xamarin.VSSDK.Tests\Xamarin.VSSDK.Tests.csproj" Targets="Build" Properties="$(AdditionalProperties);Dev=14.0" />
<Copy SourceFiles="NuGet.Config" DestinationFolder="$(Out)" />
</Target>
@ -57,46 +55,6 @@
<Exec Command='"$(Sleet)" delete -i Xamarin.VSSDK.BuildTools -v $(DeleteVersion) -s feed -c $(_SleetConfig)' ContinueOnError='true' />
</Target>
<Target Name="Test" DependsOnTargets="Build">
<PropertyGroup>
<XmlTestFile>$(Out)\TestResults.xml</XmlTestFile>
<HtmlTestFile>$(Out)\TestResults.html</HtmlTestFile>
</PropertyGroup>
<ItemGroup>
<_TestAssembly Include="test\**\bin\**\*Tests.dll" />
<TestAssembly Include="@(_TestAssembly)"
Condition="$([System.String]::new('%(Filename)').EndsWith('AcceptanceTests')) == 'false' And '%(Filename)' != 'Roslyn.Services.Editor.UnitTests'" />
</ItemGroup>
<Exec Command="&quot;$(XunitConsolePathX86)&quot; &quot;@(TestAssembly, '&quot; &quot;')&quot; $(XunitOptions) -html &quot;$(HtmlTestFile)&quot; -xml &quot;$(XmlTestFile)&quot;"
Condition="'@(TestAssembly)' != ''">
<Output TaskParameter="ExitCode" PropertyName="ExitCode" />
</Exec>
<Message Text="All tests passed, for full log see $(HtmlTestFile)" Condition="'@(TestAssembly)' != '' And '$(ExitCode)' == '0'" Importance="high" />
<Error Text="There were test failures, for full log see $(HtmlTestFile)" Condition="'@(TestAssembly)' != '' And '$(ExitCode)' != '0'" />
</Target>
<Target Name="Acceptance" DependsOnTargets="Build">
<PropertyGroup>
<XmlTestFile>$(Out)AcceptanceResults.xml</XmlTestFile>
<HtmlTestFile>$(Out)AcceptanceResults.html</HtmlTestFile>
</PropertyGroup>
<ItemGroup>
<TestAssembly Include="test\**\bin\**\*AcceptanceTests.dll" />
</ItemGroup>
<Exec Command="&quot;$(XunitConsolePathX86)&quot; &quot;@(TestAssembly, '&quot; &quot;')&quot; $(XunitOptions) -html &quot;$(HtmlTestFile)&quot; -xml &quot;$(XmlTestFile)&quot;"
Condition="'@(TestAssembly)' != ''">
<Output TaskParameter="ExitCode" PropertyName="ExitCode" />
</Exec>
<Message Text="All tests passed, for full log see $(HtmlTestFile)" Condition="'@(TestAssembly)' != '' And '$(ExitCode)' == '0'" Importance="high" />
<Error Text="There were test failures, for full log see $(HtmlTestFile)" Condition="'@(TestAssembly)' != '' And '$(ExitCode)' != '0'" />
</Target>
<Target Name="Clean">
<Exec Command='for /d /r . %%d in (bin,obj,.vs) do @if exist "%%d" rd /s/q "%%d"'
Condition="'$(OS)' == 'Windows_NT'" />
@ -111,5 +69,4 @@
</Target>
<Import Project="src\Version.targets" />
<Import Project="build\corebuild.targets" />
</Project>

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

@ -17,14 +17,23 @@ steps:
solution: build.proj
msbuildArguments: /t:Build /p:Out="$(Build.ArtifactStagingDirectory)" /bl:"$(Build.ArtifactStagingDirectory)\build.binlog"
- task: VSTest@2
displayName: Test
inputs:
testAssemblyVer2: |-
**\*.Tests.dll
!**\xunit*.dll
codeCoverageEnabled: 'true'
publishRunAttachments: 'true'
- task: MSBuild@1
displayName: Publish
displayName: Push
inputs:
solution: build.proj
msbuildArguments: /t:Publish /p:Out="$(Build.ArtifactStagingDirectory)" /p:StorageAccessKey=$(StorageAccessKey) /bl:"$(Build.ArtifactStagingDirectory)\push.binlog"
- task: PublishBuildArtifacts@1
displayName: Publish Artifact
displayName: Publish
condition: always()
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)

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

@ -46,7 +46,7 @@
<Message Text="VsixID = $(VsixID)" />
<Message Text="VsixVersion = $(VsixVersion)" />
<Message Text="VsixDeploymentPath = $(VsixDeplsoymentPath)" />
<Message Text="VsixDeploymentPath = $(VsixDeploymentPath)" />
</Target>

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

@ -16,14 +16,29 @@
</ItemDefinitionGroup>
<ItemGroup>
<PackageFile Include="Microsoft.VisualStudio.SDK.VsixSuppression" Kind="Dependency" Version="14.1.33" TargetFramework="any" />
<PackageFile Include="Microsoft.VisualStudio.SDK.VsixSuppression" Kind="Dependency" Version="14.1.37" TargetFramework="any" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="15.0.26201" PrivateAssets="all" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.1.1012" PrivateAssets="all" />
<ItemGroup Label="Visual Studio 2013">
<PackageFile Include="Microsoft.VSSDK.BuildTools" Version="12.0.21005" Kind="Dependency" TargetFramework="net45" />
</ItemGroup>
<ItemGroup Label="Visual Studio 2015">
<PackageFile Include="Microsoft.VSSDK.BuildTools" Version="14.3.25420" Kind="Dependency" TargetFramework="net452" />
</ItemGroup>
<ItemGroup Label="Visual Studio 2017">
<PackageFile Include="Microsoft.VSSDK.BuildTools" Version="15.7.109" Kind="Dependency" TargetFramework="net46" />
</ItemGroup>
<ItemGroup Label="Visual Studio 2019">
<PackageFile Include="Microsoft.VSSDK.BuildTools" Version="15.7.109" Kind="Dependency" TargetFramework="net47" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" PrivateAssets="all" />
<PackageReference Include="netfx-System.StringResources" Version="3.1.5" PrivateAssets="all" />
<PackageReference Include="NuGet.Build.Packaging" Version="0.1.323" />
<PackageReference Include="NuGet.Build.Packaging" Version="0.1.323" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>

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

@ -9,14 +9,16 @@
<PropertyGroup>
<!-- Default $(Dev) according to either '.' value or $(ActiveDebugFramework). These are explicit user-chosen values -->
<Dev Condition="'$(Dev)' == '.'">$(VisualStudioVersion)</Dev>
<Dev Condition="'$(Dev)' == '' And '$(ActiveDebugFramework)' == 'net462'">15.0</Dev>
<Dev Condition="'$(Dev)' == '' And '$(ActiveDebugFramework)' == 'net461'">14.0</Dev>
<Dev Condition="'$(Dev)' == '' And '$(ActiveDebugFramework)' == 'net46'">12.0</Dev>
<Dev Condition="'$(Dev)' == '' And '$(ActiveDebugFramework)' == 'net47'">16.0</Dev>
<Dev Condition="'$(Dev)' == '' And '$(ActiveDebugFramework)' == 'net46'">15.0</Dev>
<Dev Condition="'$(Dev)' == '' And '$(ActiveDebugFramework)' == 'net452'">14.0</Dev>
<Dev Condition="'$(Dev)' == '' And '$(ActiveDebugFramework)' == 'net45'">12.0</Dev>
<!-- If no ActiveDebugFramework was set, just set it to the one we determined, for consistency -->
<ActiveDebugFramework Condition="'$(Dev)' == '15.0'">net462</ActiveDebugFramework>
<ActiveDebugFramework Condition="'$(Dev)' == '14.0'">net461</ActiveDebugFramework>
<ActiveDebugFramework Condition="'$(Dev)' == '12.0'">net46</ActiveDebugFramework>
<ActiveDebugFramework Condition="'$(Dev)' == '16.0'">net47</ActiveDebugFramework>
<ActiveDebugFramework Condition="'$(Dev)' == '15.0'">net46</ActiveDebugFramework>
<ActiveDebugFramework Condition="'$(Dev)' == '14.0'">net452</ActiveDebugFramework>
<ActiveDebugFramework Condition="'$(Dev)' == '12.0'">net45</ActiveDebugFramework>
<XamarinVSSDKDefaultsImported>true</XamarinVSSDKDefaultsImported>
</PropertyGroup>

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

@ -25,7 +25,7 @@
</PropertyGroup>
<!-- VSIX projects generate a temp project file which doesnt have any extension and needs to be built as C# projects.
The .NET SDK just imporrts Microsoft.Common.CurrentVersion.targets.
The .NET SDK just imports Microsoft.Common.CurrentVersion.targets.
So set LanguageTargets to import CSharp.targets if the extension is unknown -->
<PropertyGroup Condition="'$(LanguageTargets)' == ''">
<LanguageTargets Condition="'$(MSBuildProjectExtension)' == '.csproj' OR '$(Language)' == 'C#'">$(MSBuildToolsPath)\Microsoft.CSharp.targets</LanguageTargets>

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

@ -25,37 +25,41 @@
</ItemDefinitionGroup>
<ItemGroup Label="Visual Studio 2013">
<PackageFile Include="VSSDK_Reference_Assemblies" Version="12.0.21005" Kind="Dependency" TargetFramework="net46" />
<PackageFile Include="VSSDK_Reference_Assemblies" Version="12.0.21005" Kind="Dependency" TargetFramework="net45" />
<!-- Missing EnvDTE + VSLangProj -->
<PackageFile Include="EnvDTE100" Version="10.0.1" Kind="Dependency" TargetFramework="net46" />
<PackageFile Include="VSLangProj100" Version="10.0.30319" Kind="Dependency" TargetFramework="net46" />
<PackageFile Include="VSLangProj110" Version="11.0.61030" Kind="Dependency" TargetFramework="net46" />
<PackageFile Include="EnvDTE100" Version="10.0.1" Kind="Dependency" TargetFramework="net45" />
<PackageFile Include="VSLangProj100" Version="10.0.30319" Kind="Dependency" TargetFramework="net45" />
<PackageFile Include="VSLangProj110" Version="11.0.61030" Kind="Dependency" TargetFramework="net45" />
<!-- Workaround for warning on wrong dep. for 12.0.* -->
<PackageFile Include="Microsoft.VisualStudio.Threading" Version="12.2.0" Kind="Dependency" TargetFramework="net46" />
<PackageFile Include="VSSDK.Shell.12" Version="12.0.4" Kind="Dependency" TargetFramework="net46" />
<PackageFile Include="VSSDK.ComponentModelHost" Version="12.0.4" Kind="Dependency" TargetFramework="net46" />
<PackageFile Include="Microsoft.VisualStudio.Threading" Version="12.2.0" Kind="Dependency" TargetFramework="net45" />
<PackageFile Include="VSSDK.Shell.12" Version="12.0.4" Kind="Dependency" TargetFramework="net45" />
<PackageFile Include="VSSDK.ComponentModelHost" Version="12.0.4" Kind="Dependency" TargetFramework="net45" />
</ItemGroup>
<ItemGroup Label="Visual Studio 2015">
<PackageFile Include="VSSDK_Reference_Assemblies" Version="14.3.25407" Kind="Dependency" TargetFramework="net461" />
<PackageFile Include="VSSDK_Reference_Assemblies" Version="14.3.25407" Kind="Dependency" TargetFramework="net452" />
<!-- Missing EnvDTE + VSLangProj -->
<PackageFile Include="EnvDTE100" Version="10.0.1" Kind="Dependency" TargetFramework="net461" />
<PackageFile Include="VSLangProj100" Version="10.0.30319" Kind="Dependency" TargetFramework="net461" />
<PackageFile Include="VSLangProj110" Version="11.0.61030" Kind="Dependency" TargetFramework="net461" />
<PackageFile Include="VSLangProj140" Version="14.0.25029" Kind="Dependency" TargetFramework="net461" />
<PackageFile Include="EnvDTE100" Version="10.0.1" Kind="Dependency" TargetFramework="net452" />
<PackageFile Include="VSLangProj100" Version="10.0.30319" Kind="Dependency" TargetFramework="net452" />
<PackageFile Include="VSLangProj110" Version="11.0.61030" Kind="Dependency" TargetFramework="net452" />
<PackageFile Include="VSLangProj140" Version="14.0.25029" Kind="Dependency" TargetFramework="net452" />
<PackageFile Include="Microsoft.VisualStudio.ComponentModelHost" Version="14.0.25424" TargetFramework="net461" Kind="Dependency" />
<PackageFile Include="Microsoft.VisualStudio.ComponentModelHost" Version="14.0.25424" TargetFramework="net452" Kind="Dependency" />
</ItemGroup>
<ItemGroup Label="Visual Studio 2017">
<PackageFile Include="VSSDK_Reference_Assemblies" Version="15.0.26608" TargetFramework="net462" Kind="Dependency" />
<PackageFile Include="VSSDK_Reference_Assemblies" Version="15.0.26608" TargetFramework="net46" Kind="Dependency" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NuGet.Build.Packaging" Version="0.1.323" />
<ItemGroup Label="Visual Studio 2019">
<PackageFile Include="VSSDK_Reference_Assemblies" Version="15.0.26608" TargetFramework="net47" Kind="Dependency" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NuGet.Build.Packaging" Version="0.1.323" PrivateAssets="all" />
</ItemGroup>
</Project>

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

@ -3,9 +3,10 @@
Declare our supported frameworks so they show up in the target framework selection dropdown.
-->
<ItemGroup>
<SupportedTargetFramework Include="net462" DisplayName="Visual Studio 2017" />
<SupportedTargetFramework Include="net461" DisplayName="Visual Studio 2015" />
<SupportedTargetFramework Include="net46" DisplayName="Visual Studio 2013" />
<SupportedTargetFramework Include="net47" DisplayName="Visual Studio 2019" />
<SupportedTargetFramework Include="net46" DisplayName="Visual Studio 2017" />
<SupportedTargetFramework Include="net452" DisplayName="Visual Studio 2015" />
<SupportedTargetFramework Include="net45" DisplayName="Visual Studio 2013" />
</ItemGroup>
<PropertyGroup>

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

@ -8,9 +8,10 @@
$(TargetFrameworks), or alternatively, by the Framework selector dropdown in 15.3+
-->
<PropertyGroup Condition="'$(Dev)' == ''">
<Dev Condition="'$(TargetFramework)' == 'net462'">15.0</Dev>
<Dev Condition="'$(TargetFramework)' == 'net461'">14.0</Dev>
<Dev Condition="'$(TargetFramework)' == 'net46'">12.0</Dev>
<Dev Condition="'$(TargetFramework)' == 'net47'">16.0</Dev>
<Dev Condition="'$(TargetFramework)' == 'net46'">15.0</Dev>
<Dev Condition="'$(TargetFramework)' == 'net452'">14.0</Dev>
<Dev Condition="'$(TargetFramework)' == 'net45'">12.0</Dev>
</PropertyGroup>
<PropertyGroup>

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

@ -25,15 +25,17 @@
cross-targeting build.
-->
<PropertyGroup Condition="'$(Dev)' != ''">
<TargetFrameworks Condition="'$(Dev)' == '15.0'">net462</TargetFrameworks>
<TargetFrameworks Condition="'$(Dev)' == '14.0'">net461</TargetFrameworks>
<TargetFrameworks Condition="'$(Dev)' == '12.0'">net46</TargetFrameworks>
<TargetFrameworks Condition="'$(Dev)' == '16.0'">net47</TargetFrameworks>
<TargetFrameworks Condition="'$(Dev)' == '15.0'">net46</TargetFrameworks>
<TargetFrameworks Condition="'$(Dev)' == '14.0'">net452</TargetFrameworks>
<TargetFrameworks Condition="'$(Dev)' == '12.0'">net45</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == '' and '$(BuildingInsideVisualStudio)' == 'true'">
<TargetFrameworks Condition="'$(VisualStudioVersion)' == '15.0'">net462</TargetFrameworks>
<TargetFrameworks Condition="'$(VisualStudioVersion)' == '14.0'">net461</TargetFrameworks>
<TargetFrameworks Condition="'$(VisualStudioVersion)' == '12.0'">net46</TargetFrameworks>
<TargetFrameworks Condition="'$(VisualStudioVersion)' == '16.0'">net47</TargetFrameworks>
<TargetFrameworks Condition="'$(VisualStudioVersion)' == '15.0'">net46</TargetFrameworks>
<TargetFrameworks Condition="'$(VisualStudioVersion)' == '14.0'">net452</TargetFrameworks>
<TargetFrameworks Condition="'$(VisualStudioVersion)' == '12.0'">net45</TargetFrameworks>
</PropertyGroup>
<!-- Visual Studio 15.3+ supports cross-targeting and loading the right MSBuild tasks version for each inner build
@ -43,16 +45,18 @@
<Target Name="EnsureNoCrossTargeting" BeforeTargets="Build"
Condition="'$(BuildingInsideVisualStudio)' != 'true' and $(TargetFrameworks.Contains(';')) and '$(TargetFramework)' == '' and '$(ExcludeRestorePackageImports)' != 'true'">
<ItemGroup>
<TargetedVisualStudio DisplayName="Visual Studio 2013 (net46, Dev=12.0)" Condition="$(TargetFrameworks.Contains('net46'))" />
<TargetedVisualStudio DisplayName="Visual Studio 2015 (net461, Dev=14.0)" Condition="$(TargetFrameworks.Contains('net461'))" />
<TargetedVisualStudio DisplayName="Visual Studio 2017 (net462, Dev=15.0)" Condition="$(TargetFrameworks.Contains('net462'))" />
</ItemGroup>
<TargetedVisualStudio DisplayName="Visual Studio 2013 (net45, Dev=12.0)" Condition="$(TargetFrameworks.Contains('net45'))" />
<TargetedVisualStudio DisplayName="Visual Studio 2015 (net452, Dev=14.0)" Condition="$(TargetFrameworks.Contains('net452'))" />
<TargetedVisualStudio DisplayName="Visual Studio 2017 (net46, Dev=15.0)" Condition="$(TargetFrameworks.Contains('net46'))" />
<TargetedVisualStudio DisplayName="Visual Studio 2019 (net47, Dev=16.0)" Condition="$(TargetFrameworks.Contains('net47'))" />
</ItemGroup>
<Error Code="XVSSDK0001" Text="In order to build cross-targeting VSIXes, each targeted IDE must be built separately.
You can use either /p:TargetFramework or the aliased /p:Dev property to build for each.
For Visual Studio 2013, specify: /p:Dev=12.0 or /p:TargetFramework=net46
For Visual Studio 2015, specify: /p:Dev=14.0 or /p:TargetFramework=net461
For Visual Studio 2017, specify: /p:Dev=15.0 or /p:TargetFramework=net462
For Visual Studio 2013, specify: /p:Dev=12.0 or /p:TargetFramework=net45
For Visual Studio 2015, specify: /p:Dev=14.0 or /p:TargetFramework=net452
For Visual Studio 2017, specify: /p:Dev=15.0 or /p:TargetFramework=net46
For Visual Studio 2019, specify: /p:Dev=16.0 or /p:TargetFramework=net47
The current project targets: @(TargetedVisualStudio, ',')." />
</Target>

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

@ -34,7 +34,7 @@ AssemblyVersion=$(AssemblyVersion)" />
</Target>
<!-- '$(ExcludeRestorePackageImports)' == 'true' when invoking /t:Restore -->
<Target Name="SetVersion" BeforeTargets="Build;GetPackageVersion" DependsOnTargets="GitVersion" Condition="'$(ExcludeRestorePackageImports)' != 'true'">
<Target Name="SetVersion" BeforeTargets="GetAssemblyVersion;GetPackageVersion" DependsOnTargets="GitVersion" Condition="'$(ExcludeRestorePackageImports)' != 'true'">
<PropertyGroup>
<!-- PR builds are *always* prerelease -->
<!-- TFS case: BUILD_REASON=PullRequest and BUILD_SOURCEBRANCH=refs/pull/#/merge -->

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

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27110.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.28021.4002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.VSSDK", "VSSDK\Xamarin.VSSDK.csproj", "{8224B403-29E1-49D9-B023-D82C2A0CA807}"
EndProject
@ -10,7 +10,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{99515836-5C56-48C5-88A1-74F0029FA2C5}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
..\build.cmd = ..\build.cmd
..\build.proj = ..\build.proj
..\build.yml = ..\build.yml
Directory.Build.props = Directory.Build.props

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

@ -1,23 +0,0 @@
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- MSBuild 4 > 15.1 -->
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="15.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="15.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Tasks.Core" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="15.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Utilities.Core" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="15.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

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

@ -14,7 +14,7 @@ using Xunit.Abstractions;
/// automatic solution-configuration generation for
/// P2P references.
/// </summary>
public static partial class Builder
static partial class Builder
{
const string ToolsVersion = "15.0";

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

@ -0,0 +1,7 @@
internal static class ModuleInitializer
{
internal static void Run()
{
Microsoft.Build.Locator.MSBuildLocator.RegisterMSBuildPath(ThisAssembly.Project.Properties.MSBuildBinPath);
}
}

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

@ -11,9 +11,9 @@ namespace Xamarin.VSSDK.Tests
public class TargetsTests
{
// This resolves the SDKs to the same location that was used to compile this project.
static TargetsTests() => Environment.SetEnvironmentVariable(
nameof(ThisAssembly.Project.Properties.MSBuildSDKsPath),
ThisAssembly.Project.Properties.MSBuildSDKsPath);
//static TargetsTests() => Environment.SetEnvironmentVariable(
// nameof(ThisAssembly.Project.Properties.MSBuildSDKsPath),
// ThisAssembly.Project.Properties.MSBuildSDKsPath);
ITestOutputHelper output;
@ -24,10 +24,11 @@ namespace Xamarin.VSSDK.Tests
{
var project = new ProjectInstance("Template.csproj", new Dictionary<string, string>
{
{ "TargetFrameworks", "net46;net461;net462" },
{ "TargetFrameworks", "net45;net452;net46" },
{ "Configuration", ThisAssembly.Project.Properties.Configuration },
}, "15.0", new ProjectCollection());
Builder.Build(project, "Restore");
var result = Builder.Build(project, "Build");
Assert.Equal(BuildResultCode.Failure, result.BuildResult.OverallResult);
@ -39,11 +40,12 @@ namespace Xamarin.VSSDK.Tests
{
var project = new ProjectInstance("Template.csproj", new Dictionary<string, string>
{
{ "TargetFrameworks", "net46;net461;net462" },
{ "TargetFrameworks", "net45;net452;net46" },
{ "BuildingInsideVisualStudio", "true" },
{ "Configuration", ThisAssembly.Project.Properties.Configuration },
}, "15.0", new ProjectCollection());
Builder.Build(project, "Restore");
var result = Builder.Build(project, "Build");
Assert.Equal(BuildResultCode.Success, result.BuildResult.OverallResult);
@ -55,13 +57,13 @@ namespace Xamarin.VSSDK.Tests
{
var project = new Project("Template.csproj", new Dictionary<string, string>
{
{ "TargetFrameworks", "net46;net461;net462" },
{ "ActiveDebugFramework", "net461" },
{ "TargetFrameworks", "net45;net452;net46" },
{ "ActiveDebugFramework", "net452" },
{ "Configuration", ThisAssembly.Project.Properties.Configuration },
{ "BuildingInsideVisualStudio", "true" }
}, "15.0", new ProjectCollection());
Assert.Equal("net461", project.GetPropertyValue("TargetFramework"));
Assert.Equal("net452", project.GetPropertyValue("TargetFramework"));
}
[Fact]
@ -69,12 +71,12 @@ namespace Xamarin.VSSDK.Tests
{
var project = new Project("Template.csproj", new Dictionary<string, string>
{
{ "TargetFrameworks", "net46;net461;net462" },
{ "ActiveDebugFramework", "net461" },
{ "TargetFrameworks", "net45;net452;net46" },
{ "ActiveDebugFramework", "net452" },
{ "Configuration", ThisAssembly.Project.Properties.Configuration },
}, "15.0", new ProjectCollection());
Assert.NotEqual("net461", project.GetPropertyValue("TargetFramework"));
Assert.NotEqual("net452", project.GetPropertyValue("TargetFramework"));
}
[Fact]
@ -82,12 +84,12 @@ namespace Xamarin.VSSDK.Tests
{
var project = new Project("Template.csproj", new Dictionary<string, string>
{
{ "TargetFrameworks", "net46;net461;net462" },
{ "TargetFrameworks", "net45;net452;net46" },
{ "Dev", "15.0" },
{ "Configuration", ThisAssembly.Project.Properties.Configuration },
}, "15.0", new ProjectCollection());
Assert.Equal("net462", project.GetPropertyValue("TargetFrameworks"));
Assert.Equal("net46", project.GetPropertyValue("TargetFrameworks"));
}
[Fact]
@ -95,14 +97,14 @@ namespace Xamarin.VSSDK.Tests
{
var project = new Project("Template.csproj", new Dictionary<string, string>
{
{ "TargetFrameworks", "net46;net461;net462" },
{ "ActiveDebugFramework", "net461" },
{ "TargetFrameworks", "net45;net452;net46" },
{ "ActiveDebugFramework", "net452" },
{ "Dev", "15.0" },
{ "Configuration", ThisAssembly.Project.Properties.Configuration },
{ "BuildingInsideVisualStudio", "true" },
}, "15.0", new ProjectCollection());
Assert.Equal("net462", project.GetPropertyValue("TargetFramework"));
Assert.Equal("net46", project.GetPropertyValue("TargetFramework"));
}
[Fact]
@ -110,12 +112,12 @@ namespace Xamarin.VSSDK.Tests
{
var project = new Project("Template.csproj", new Dictionary<string, string>
{
{ "TargetFrameworks", "net46;net461;net462" },
{ "TargetFrameworks", "net45;net452;net46" },
{ "Dev", "15.0" },
{ "Configuration", ThisAssembly.Project.Properties.Configuration },
}, "15.0", new ProjectCollection());
Assert.Equal("net462", project.GetPropertyValue("TargetFrameworks"));
Assert.Equal("net46", project.GetPropertyValue("TargetFrameworks"));
}
[Fact]
@ -123,8 +125,8 @@ namespace Xamarin.VSSDK.Tests
{
var project = new Project("Template.csproj", new Dictionary<string, string>
{
{ "TargetFrameworks", "net46;net461;net462" },
{ "TargetFramework", "net461" },
{ "TargetFrameworks", "net45;net452;net46" },
{ "TargetFramework", "net452" },
{ "Configuration", ThisAssembly.Project.Properties.Configuration },
}, "15.0", new ProjectCollection());

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

@ -2,92 +2,90 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Build.Framework;
using Xunit.Abstractions;
namespace Microsoft.Build.Framework
/// <summary>
/// Fake build engine for unit testing Tasks without spinning up
/// MSBuild.
/// </summary>
class MockBuildEngine : IBuildEngine
{
/// <summary>
/// Fake build engine for unit testing Tasks without spinning up
/// MSBuild.
/// </summary>
public class MockBuildEngine : IBuildEngine
{
bool trace = false;
ITestOutputHelper output;
bool trace = false;
ITestOutputHelper output;
public MockBuildEngine(bool trace = true)
{
this.trace = trace;
LoggedCustomEvents = new List<CustomBuildEventArgs>();
LoggedErrorEvents = new List<BuildErrorEventArgs>();
LoggedMessageEvents = new List<BuildMessageEventArgs>();
LoggedWarningEvents = new List<BuildWarningEventArgs>();
}
public MockBuildEngine(bool trace = true)
{
this.trace = trace;
LoggedCustomEvents = new List<CustomBuildEventArgs>();
LoggedErrorEvents = new List<BuildErrorEventArgs>();
LoggedMessageEvents = new List<BuildMessageEventArgs>();
LoggedWarningEvents = new List<BuildWarningEventArgs>();
}
public MockBuildEngine(ITestOutputHelper output, bool trace = false)
: this(trace)
{
this.output = output;
}
public MockBuildEngine(ITestOutputHelper output, bool trace = false)
: this(trace)
{
this.output = output;
}
public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs)
{
throw new NotSupportedException();
}
public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs)
{
throw new NotSupportedException();
}
public int ColumnNumberOfTaskNode { get; set; }
public int ColumnNumberOfTaskNode { get; set; }
public bool ContinueOnError { get; set; }
public bool ContinueOnError { get; set; }
public int LineNumberOfTaskNode { get; set; }
public int LineNumberOfTaskNode { get; set; }
public string ProjectFileOfTaskNode { get; set; }
public string ProjectFileOfTaskNode { get; set; }
public List<CustomBuildEventArgs> LoggedCustomEvents { get; private set; }
public List<BuildErrorEventArgs> LoggedErrorEvents { get; private set; }
public List<BuildMessageEventArgs> LoggedMessageEvents { get; private set; }
public List<BuildWarningEventArgs> LoggedWarningEvents { get; private set; }
public List<CustomBuildEventArgs> LoggedCustomEvents { get; private set; }
public List<BuildErrorEventArgs> LoggedErrorEvents { get; private set; }
public List<BuildMessageEventArgs> LoggedMessageEvents { get; private set; }
public List<BuildWarningEventArgs> LoggedWarningEvents { get; private set; }
public void LogCustomEvent(CustomBuildEventArgs e)
{
if (trace)
TraceMessage(e.Message);
public void LogCustomEvent(CustomBuildEventArgs e)
{
if (trace)
TraceMessage(e.Message);
LoggedCustomEvents.Add(e);
}
LoggedCustomEvents.Add(e);
}
public void LogErrorEvent(BuildErrorEventArgs e)
{
if (trace)
TraceMessage(e.Message);
public void LogErrorEvent(BuildErrorEventArgs e)
{
if (trace)
TraceMessage(e.Message);
LoggedErrorEvents.Add(e);
}
LoggedErrorEvents.Add(e);
}
public void LogMessageEvent(BuildMessageEventArgs e)
{
if (trace)
TraceMessage(e.Message);
public void LogMessageEvent(BuildMessageEventArgs e)
{
if (trace)
TraceMessage(e.Message);
LoggedMessageEvents.Add(e);
}
LoggedMessageEvents.Add(e);
}
public void LogWarningEvent(BuildWarningEventArgs e)
{
if (trace)
TraceMessage(e.Message);
public void LogWarningEvent(BuildWarningEventArgs e)
{
if (trace)
TraceMessage(e.Message);
LoggedWarningEvents.Add(e);
}
LoggedWarningEvents.Add(e);
}
void TraceMessage(string message)
{
Console.WriteLine(message);
Trace.WriteLine(message);
Debug.WriteLine(message);
Debugger.Log(0, "", message);
if (output != null)
output.WriteLine(message);
}
}
void TraceMessage(string message)
{
Console.WriteLine(message);
Trace.WriteLine(message);
Debug.WriteLine(message);
Debugger.Log(0, "", message);
if (output != null)
output.WriteLine(message);
}
}

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

@ -2,7 +2,7 @@
namespace NuGet.Build.Packaging
{
public static class TaskItemExtensions
static class TaskItemExtensions
{
/// <summary>
/// Checks if the given item has metadata key/values matching the

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

@ -5,13 +5,11 @@ using Xunit.Abstractions;
/// <summary>
/// xunit logger > MSBuild logger
/// </summary>
public class TestOutputLogger : ILogger
class TestOutputLogger : ILogger
{
ITestOutputHelper output;
public TestOutputLogger(ITestOutputHelper output, LoggerVerbosity? verbosity = LoggerVerbosity.Quiet)
public TestOutputLogger(ITestOutputHelper output, LoggerVerbosity? verbosity = LoggerVerbosity.Quiet)
{
this.output = output;
this.Output = output;
Verbosity = verbosity.GetValueOrDefault();
}
@ -24,9 +22,9 @@ public class TestOutputLogger : ILogger
FinishedTasks = new List<TaskFinishedEventArgs>();
}
public ITestOutputHelper Output => output;
public ITestOutputHelper Output { get; }
public LoggerVerbosity Verbosity { get; set; }
public LoggerVerbosity Verbosity { get; set; }
public List<BuildMessageEventArgs> Messages { get; private set; } = new List<BuildMessageEventArgs>();
@ -46,7 +44,7 @@ public class TestOutputLogger : ILogger
eventSource.AnyEventRaised += (sender, e) =>
{
if (!(e is BuildMessageEventArgs) && Verbosity > LoggerVerbosity.Normal)
output?.WriteLine(e.Message);
Output?.WriteLine(e.Message);
};
eventSource.MessageRaised += (sender, e) =>
@ -65,21 +63,21 @@ public class TestOutputLogger : ILogger
}
if (Verbosity != LoggerVerbosity.Quiet && shouldLog)
output?.WriteLine(e.Message);
Output?.WriteLine(e.Message);
Messages.Add(e);
};
eventSource.ErrorRaised += (sender, e) =>
{
output?.WriteLine(e.Message);
Output?.WriteLine(e.Message);
Errors.Add(e);
};
eventSource.WarningRaised += (sender, e) =>
{
if (Verbosity != LoggerVerbosity.Quiet)
output?.WriteLine(e.Message);
Output?.WriteLine(e.Message);
Warnings.Add(e);
};

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<TargetFramework>net46</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
@ -40,37 +40,39 @@
<ThisAssemblyProjectProperty Include="CSharpCoreTargetsPath" />
<ThisAssemblyProjectProperty Include="RoslynTargetsPath" />
<ThisAssemblyProjectProperty Include="MSBuildSDKsPath" />
<ThisAssemblyProjectProperty Include="MSBuildBinPath" />
<ThisAssemblyProjectProperty Include="MSBuildExtensionsPath" />
<ThisAssemblyProjectProperty Include="NuGetRestoreTargets" />
<!-- Need to deploy Roslyn code analysis/compiler for VSIX build/deploy to succeed -->
<!--
Need to deploy Roslyn code analysis/compiler for VSIX build/deploy to succeed --><!--
<None Include="$(RoslynTargetsPath)\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>Roslyn\%(Filename)%(Extension)</Link>
<Visible>false</Visible>
</None>
-->
<!-- Hide contentFiles coming from nuget packages (in particular, Microsoft.Build.Runtime) -->
<!--
<None Update="@(None)">
<Visible>$([MSBuild]::ValueOrDefault('%(None.NuGetPackageId)', '').Equals(''))</Visible>
</None>
<Folder Update="15.0">
<Visible>false</Visible>
</Folder>
-->
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Logging.StructuredLogger" Version="1.1.168" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="MSBuilder.ThisAssembly.Project" Version="0.3.4" />
<PackageReference Include="InjectModuleInitializer" Version="2.0.0" />
<PackageReference Include="Mvp.Xml" Version="2.3.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="xunit.vsix" Version="0.3.12-beta" />
<PackageReference Include="Microsoft.Build" Version="15.3.409" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.3.409" />
<!-- Allows loading and evaluating 15.3+ projects -->
<PackageReference Include="Microsoft.Build.Runtime" Version="15.3.409" />
<PackageReference Include="Microsoft.Build" Version="15.8.166" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.8.166" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.0.18" />
<PackageReference Include="Microsoft.Build.Logging.StructuredLogger" Version="1.1.168" />
<!-- Allows loading and evaluating VSSDK projects -->
<PackageReference Include="VSSDK_Reference_Assemblies" Version="15.0.26608" />
</ItemGroup>

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

@ -1,3 +1,4 @@
{
"methodDisplay": "method"
"methodDisplay": "method",
"shadowCopy": false
}