Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 68dea7b

Browse files
authored
Merge pull request #92 from adalon/dev
Ensuring the LegacyCSProject is used for NuProj
2 parents 2fa6c67 + 9974c65 commit 68dea7b

36 files changed

Lines changed: 380 additions & 173 deletions

appveyor.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
os: Visual Studio 2015
1+
os: Visual Studio 2017 RC
22

33
init:
44
- ps: >-
@@ -11,11 +11,10 @@ init:
1111
}
1212
1313
build_script:
14-
# Ensure we have no dangling MSBuild processes that might lock the output assemblies
15-
- cmd: taskkill /f /im MSBuild.exe /fi "memusage gt 40" 2>NUL
16-
- cmd: build.cmd %BuildArgs%
17-
# Ensure we leave no dangling MSBuild processes
18-
- cmd: taskkill /f /im MSBuild.exe /fi "memusage gt 40" 2>NUL
14+
- cmd: taskkill /f /im MSBuild.exe /fi "memusage gt 40" 2>NUL
15+
- cmd: build.cmd /restore
16+
- cmd: build.cmd
17+
- cmd: taskkill /f /im MSBuild.exe /fi "memusage gt 40" 2>NUL
1918

2019
install:
2120
- cmd: git submodule update --init --recursive
@@ -41,7 +40,7 @@ nuget:
4140
disable_publish_on_pr: false
4241

4342
artifacts:
44-
- path: '*.nupkg'
43+
- path: 'out\*.nupkg'
4544
name: Package
46-
- path: '*.vsix'
45+
- path: 'out\*.vsix'
4746
name: Extension

build.cmd

Lines changed: 101 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,111 @@
1-
:: Optional batch file to quickly build with some defaults.
2-
:: Alternatively, this batch file can be invoked passing msbuild parameters, like: build.cmd "/v:detailed" "/t:Rebuild"
1+
@echo off
2+
setlocal enabledelayedexpansion
33

4-
@ECHO OFF
4+
set BatchFile=%0
5+
set Root=%~dp0
6+
set BuildConfiguration=Debug
7+
set MSBuildTarget=All
8+
set NodeReuse=true
9+
set MultiProcessor=/m
510

6-
:: Ensure MSBuild can be located. Allows for a better error message below.
7-
where msbuild > %TEMP%\msbuild.txt
8-
set /p msb=<%TEMP%\msbuild.txt
11+
:ParseArguments
12+
if "%1" == "" goto :DoneParsing
13+
if /I "%1" == "/?" call :Usage && exit /b 1
14+
if /I "%1" == "/debug" set BuildConfiguration=Debug&&shift&& goto :ParseArguments
15+
if /I "%1" == "/release" set BuildConfiguration=Release&&shift&& goto :ParseArguments
16+
if /I "%1" == "/build" set MSBuildTarget=Build&&shift&& goto :ParseArguments
17+
if /I "%1" == "/rebuild" set MSBuildTarget=Rebuild&&shift&& goto :ParseArguments
18+
if /I "%1" == "/package" set MSBuildTarget=Package&&shift&& goto :ParseArguments
19+
if /I "%1" == "/test" set MSBuildTarget=Test&&shift&& goto :ParseArguments
20+
if /I "%1" == "/restore" set MSBuildTarget=Restore&&shift&& goto :ParseArguments
21+
if /I "%1" == "/no-node-reuse" set NodeReuse=false&&shift&& goto :ParseArguments
22+
if /I "%1" == "/no-multi-proc" set MultiProcessor=&&shift&& goto :ParseArguments
23+
MSBuildAdditionalArguments="%1 %MSBuildAdditionalArguments"%&&shift&& goto :ParseArguments
24+
:DoneParsing
925

10-
IF "%msb%"=="" (
11-
echo Please run %~n0 from a Visual Studio Developer Command Prompt.
12-
exit /b -1
26+
:: Detect if MSBuild is in the path
27+
for /f "delims=" %%i in ('where msbuild') do set "MSBuildPath=%%i" & goto :MSBuildPathDone
28+
:MSBuildPathDone
29+
30+
if not exist "%MSBuildPath%" (
31+
call :PrintColor Red "To build this repository, MSBuild.exe must be in the PATH."
32+
echo MSBuild is included with Visual Studio 2017 or later.
33+
echo.
34+
echo If Visual Studio is not installed, visit this page to download:
35+
echo.
36+
echo https://www.visualstudio.com/vs/
37+
echo.
38+
exit /b 1
1339
)
1440

15-
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
41+
:: Detect MSBuild version >= 15
42+
for /f "delims=" %%i in ('msbuild -nologo -version') do set MSBuildFullVersion=%%i
43+
for /f "delims=. tokens=1" %%a in ("%MSBuildFullVersion%") do (
44+
set MSBuildMajorVersion=%%a
45+
)
1646

17-
IF EXIST .nuget\nuget.exe goto restore
18-
IF NOT EXIST .nuget md .nuget
19-
echo Downloading latest version of NuGet.exe...
20-
@powershell -NoProfile -ExecutionPolicy RemoteSigned -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile .nuget/nuget.exe"
47+
if %MSBuildMajorVersion% LSS 15 (
48+
call :PrintColor Red "To build this repository, the MSBuild.exe in the PATH needs to be 15.0 or higher."
49+
echo MSBuild 15.0 is included with Visual Studio 2017 or later.
50+
echo.
51+
echo If Visual Studio is not installed, visit this page to download:
52+
echo.
53+
echo https://www.visualstudio.com/vs/
54+
echo.
55+
echo Located MSBuild in the PATH was "%MSBuildPath%".
56+
exit /b 1
57+
)
2158

22-
:restore
23-
:: Build script packages have no version in the path, so we install them to .nuget\packages to avoid conflicts with
24-
:: solution/project packages.
25-
IF NOT EXIST packages.config goto run
26-
.nuget\nuget.exe install packages.config -OutputDirectory .nuget\packages -ExcludeVersion -Verbosity quiet
59+
:: Ensure developer command prompt variables are set
60+
if "%VisualStudioVersion%" == "" (
61+
for /f "delims=" %%i in ('msbuild build.props -nologo /t:GetVsInstallRoot') do set "VsInstallRoot=%%i" & goto :VsInstallRootDone
62+
:VsInstallRootDone
63+
for /f "tokens=* delims= " %%i in ("%VsInstallRoot%") do set "VsInstallRoot=%%i"
64+
set "DeveloperCommandPrompt=%VsInstallRoot%\Common7\Tools\VsDevCmd.bat"
65+
if not exist "%DeveloperCommandPrompt%" (
66+
call :PrintColor Red "Failed to locate 'Common7\Tools\VsDevCmd.bat' under the reported Visual Studio installation root '%VsInstallRoot%'."
67+
echo.
68+
echo If Visual Studio is not installed, visit this page to download:
69+
echo.
70+
echo https://www.visualstudio.com/vs/
71+
echo.
72+
exit /b 1
73+
)
74+
call "%DeveloperCommandPrompt%" || goto :BuildFailed
75+
)
2776

28-
:run
29-
IF "%Verbosity%"=="" (
30-
set Verbosity=minimal
77+
msbuild /nologo /nodeReuse:%NodeReuse% /t:"%MSBuildTarget%" /p:Configuration="%BuildConfiguration%" %MSBuildAdditionalArguments%
78+
if ERRORLEVEL 1 (
79+
echo.
80+
call :PrintColor Red "Build failed, for full log see msbuild.log."
81+
exit /b 1
3182
)
3283

33-
"%msb%" build.proj /v:%Verbosity% %1 %2 %3 %4 %5 %6 %7 %8 %9
84+
echo.
85+
call :PrintColor Green "Build completed successfully, for full log see msbuild.log"
86+
exit /b 0
87+
88+
:Usage
89+
echo Usage: %BatchFile% [/build^|/rebuild^|/test^|/restore^] [/debug^|/release] [/no-node-reuse] [/no-multi-proc]
90+
echo.
91+
echo Build targets:
92+
echo /build Perform build
93+
echo /rebuild Perform a clean, then build
94+
echo /package Packages the product
95+
echo /test Builds and runs tests only
96+
echo /restore Only restore NuGet packages
97+
echo.
98+
echo Build options:
99+
echo /debug Perform debug build (default)
100+
echo /release Perform release build
101+
echo /no-node-reuse Prevents MSBuild from reusing existing MSBuild instances,
102+
echo useful for avoiding unexpected behavior on build machines
103+
echo /no-multi-proc No multi-proc build, useful for diagnosing build logs
104+
goto :eof
105+
106+
:BuildFailed
107+
call :PrintColor Red "Build failed with ERRORLEVEL %ERRORLEVEL%"
108+
exit /b 1
109+
110+
:PrintColor
111+
"%Windir%\System32\WindowsPowerShell\v1.0\Powershell.exe" -noprofile write-host -foregroundcolor %1 "'%2'"

build.proj

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
<PropertyGroup Condition="'$(IsCIBuild)' == 'true'">
1010
<Configuration Condition=" '$(Configuration)' == ''">Release</Configuration>
1111
</PropertyGroup>
12-
12+
1313
<PropertyGroup>
14+
<NuGetUrl Condition=" '$(NuGetUrl)' == '' ">https://dist.nuget.org/win-x86-commandline/v3.4.4/NuGet.exe</NuGetUrl>
15+
<RestorePackages>false</RestorePackages>
16+
<Out Condition=" '$(Out)' == '' ">$(MSBuildThisFileDirectory)out</Out>
1417
<RunCodeAnalysis Condition=" '$(RunCodeAnalysis)' == ''">false</RunCodeAnalysis>
1518
<IntermediateOutputPath>.nuget\</IntermediateOutputPath>
1619
<PackagesPath>$(IntermediateOutputPath)packages</PackagesPath>
@@ -40,7 +43,6 @@
4043
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
4144

4245
<Target Name="Build">
43-
<MSBuild Projects="src\VisualStudio\NuGet.Packaging.VisualStudio.sln" Targets="RestorePackages" />
4446
<Exec Command="rmdir $(Out) /S /Q" Condition=" Exists('$(Out)') " ContinueOnError="true" StandardOutputImportance="low" />
4547
<MakeDir Directories="$(Out)" Condition="!Exists('$(Out)')" />
4648
<Message Text="Build properties: $(CommonBuildProperties)." Importance="high" />
@@ -66,10 +68,24 @@
6668
</ItemGroup>
6769
<MakeDir Directories="$(Out)" Condition="!Exists('$(Out)')" />
6870

69-
<xunit Assemblies="@(TestAssembly)"
70-
Html="$(Out)\test.html"
71-
Xml="$(Out)\test.xml"
72-
Reporter="appveyor" />
71+
<PropertyGroup>
72+
<XunitConsole>"$(PackagesPath)\xunit.runner.console\tools\xunit.console.exe"</XunitConsole>
73+
<XunitOptions>$(XunitOptions) -html $(Out)\test.html -xml $(Out)\test.xml -parallel all -noshadow</XunitOptions>
74+
</PropertyGroup>
75+
76+
<Exec Command="$(XunitConsole) @(TestAssembly, ' ') $(XunitOptions)" ConsoleToMSBuild="true" />
77+
</Target>
78+
79+
<Target Name="Restore">
80+
81+
<Exec Command='"$(NuGet)" Restore "external\ApiIntersect\ApiIntersect.sln" -Verbosity quiet' />
82+
<Exec Command='"$(NuGet)" Restore "src\Build\NuGet.Build.Packaging.sln" -Verbosity quiet -Config src\NuGet.Config' />
83+
<Exec Command='"$(NuGet)" Restore "src\Build\NuGet.Build.Packaging.Tests\Scenarios\given_a_library_with_non_nugetized_reference\b.sln"' />
84+
<Exec Command='"$(NuGet)" Restore "src\Build\NuGet.Build.Packaging.Tests\Scenarios\given_a_multi_platform_solution\forms.sln"' />
85+
<Exec Command='"$(NuGet)" Restore "src\Build\NuGet.Build.Packaging.Tests\Scenarios\given_library_with_json_dependencies\project.json"' />
86+
87+
<!-- Ignore error code here since NuGet will detect an incompatibility between VS2017 ProjectSystem NuGet on MSBuild 15+, and the tasks' MSBuild 14, which is intentional -->
88+
<Exec Command='"$(NuGet)" Restore "src\VisualStudio\NuGet.Packaging.VisualStudio.sln" -Verbosity quiet -Config src\NuGet.Config' IgnoreExitCode='true' />
7389
</Target>
7490

7591
<Target Name="Coverage" DependsOnTargets="Build">
@@ -83,7 +99,7 @@
8399
<MakeDir Directories="$(Out)" Condition="!Exists('$(Out)')" />
84100

85101
<PropertyGroup>
86-
<XunitOptions>$(XunitOptions) -html $(Out)\test.html -xml $(Out)\test.xml -parallel none -noshadow</XunitOptions>
102+
<XunitOptions>$(XunitOptions) -html $(Out)\test.html -xml $(Out)\test.xml -parallel none -noshadow </XunitOptions>
87103

88104
<CoverageConsole>$(PackagesPath)\OpenCover\tools\OpenCover.Console.exe</CoverageConsole>
89105
<CoverageOptions>$(CoverageOptions) -output:$(Out)\coverage.xml -returntargetcode -register:user -filter:"+[NuGet.Build.Packaging*]* -[NuGet.Packaging.Core*]* -[NuGet.Packaging.VisualStudio*]* -[Clide*]* -[xunit*]* -[*Tests]* -[*]*ThisAssembly*" -excludebyattribute:*ExcludeFromCodeCoverage*;*CompilerGenerated* -skipautoprops -showunvisited -mergebyhash</CoverageOptions>
@@ -120,7 +136,13 @@
120136
<PendingRestore Condition=" !Exists('$(GitInfoTargets)') Or !Exists('$(XunitConsole)') Or !Exists('$(XunitProps)') ">true</PendingRestore>
121137
</PropertyGroup>
122138
<Import Project="$(XunitProps)" Condition="Exists('$(XunitProps)')"/>
123-
<Target Name="GitVersion" />
139+
<Target Name="GitVersion">
140+
<PropertyGroup>
141+
<GitSemVerMajor>1</GitSemVerMajor>
142+
<GitSemVerMinor>0</GitSemVerMinor>
143+
<GitSemVerPatch>0</GitSemVerPatch>
144+
</PropertyGroup>
145+
</Target>
124146
<Import Project="$(GitInfoTargets)" Condition="Exists('$(GitInfoTargets)')"/>
125147
<Import Project="src\PackageVersion.targets" />
126148

build.props

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<IsCIBuild Condition=" '$(IsTeamCityBuild)' == 'true' Or '$(IsWrenchBuild)' == 'true' Or '$(IsAppVeyorBuild)' == 'true' Or '$(IsMyGetBuild)' == 'true' Or '$(IsJenkinsBuild)' == 'true' ">true</IsCIBuild>
1313
</PropertyGroup>
1414

15-
<PropertyGroup>
16-
<Out Condition=" '$(Out)' == '' ">$(MSBuildThisFileDirectory)out</Out>
17-
</PropertyGroup>
15+
<Target Name="GetVsInstallRoot" Returns="$(VsInstallRoot)">
16+
<Message Importance="high" Text="$(VsInstallRoot)" />
17+
</Target>
18+
1819
</Project>

msbuild.rsp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/consoleloggerparameters:Verbosity=minimal
2+
/fileLogger
3+
/fileloggerparameters:LogFile=msbuild.log;verbosity=detailed

src/Build/Before.NuGet.Build.Packaging.sln.targets

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Build/NuGet.Build.Packaging.Tasks.Shared.targets

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), NuGet.Build.Packaging.Shared.targets))\NuGet.Build.Packaging.Shared.targets" />
44

5-
<Target Name="AddMSBuildReferences" BeforeTargets="ResolveAssemblyReferences">
6-
<ItemGroup>
7-
<!-- TODO: to replace with the MSBuild nugets once they are more generally available -->
8-
<Reference Include="Microsoft.Build">
9-
<HintPath>$(MSBuildBinPath)\Microsoft.Build.dll</HintPath>
10-
</Reference>
11-
<Reference Include="Microsoft.Build.Framework">
12-
<HintPath>$(MSBuildBinPath)\Microsoft.Build.Framework.dll</HintPath>
13-
</Reference>
14-
<Reference Include="Microsoft.Build.Tasks.Core">
15-
<HintPath>$(MSBuildBinPath)\Microsoft.Build.Tasks.Core.dll</HintPath>
16-
</Reference>
17-
<Reference Include="Microsoft.Build.Utilities.Core">
18-
<HintPath>$(MSBuildBinPath)\Microsoft.Build.Utilities.Core.dll</HintPath>
19-
</Reference>
20-
</ItemGroup>
21-
</Target>
22-
235
<PropertyGroup>
246
<!-- We'll include the PackageFiles ourselves -->
257
<IncludeOutputs>false</IncludeOutputs>

src/Build/NuGet.Build.Packaging.Tasks/GenerateReferenceAssembly.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
<WarningLevel>4</WarningLevel>
2525
</PropertyGroup>
2626
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
27-
2827
<PropertyGroup>
2928
<PrepareResourcesDependsOn>
3029
_CollectCompileFiles;

src/Build/NuGet.Build.Packaging.Tasks/NuGet.Build.Packaging.Tasks.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<ProjectGuid>{A3D231D7-31E4-4A70-8CD1-7246C7D069F6}</ProjectGuid>
77
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
8-
<TargetFrameworkProfile />
98
</PropertyGroup>
109
<ItemGroup>
1110
<Reference Include="System" />
@@ -29,10 +28,6 @@
2928
<Content Include="NuGet.Build.Packaging.Authoring.targets">
3029
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3130
</Content>
32-
<None Include="..\..\..\external\ApiIntersect\ApiIntersect\app.config">
33-
<Link>ApiIntersect.exe.config</Link>
34-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
35-
</None>
3631
<None Include="NuGet.Build.Packaging.Version.props">
3732
<SubType>Designer</SubType>
3833
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

0 commit comments

Comments
 (0)