|
1 | 1 | <Project DefaultTargets="UnitTest" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
2 | | - |
3 | | - <!-- Update NuGet Package version for nightly build--> |
4 | | - <PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.nuproj'"> |
5 | | - <NuGetPackageVersion Condition="'$(UpdateNightlyPackages)' == 'true'">$(NuGetPackageVersion)-b$(VersionBuild)</NuGetPackageVersion> |
| 2 | + <PropertyGroup> |
| 3 | + <NupkgToolPath>$(RepositoryRoot)src\Packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform\tools\</NupkgToolPath> |
| 4 | + <LocalRoslynFolderName>Roslyn45</LocalRoslynFolderName> |
| 5 | + <LocalLatestRoslynFolderName>RoslynLatest</LocalLatestRoslynFolderName> |
6 | 6 | </PropertyGroup> |
7 | | - |
8 | | - <ItemGroup> |
9 | | - <NuGetInstallScripts Include="$(RepositoryRootEx)src\Packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform\tools\*.ps1"/> |
10 | | - </ItemGroup> |
11 | | - |
12 | | - <Target Name="CopyInstallScripts"> |
13 | | - <Copy SourceFiles="@(NuGetInstallScripts)" |
14 | | - DestinationFolder="$(AssemblyPath)" |
15 | | - /> |
16 | | - </Target> |
17 | 7 |
|
| 8 | + <UsingTask TaskName="DownloadRoslynBinaries" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
| 9 | + <ParameterGroup> |
| 10 | + <NupkgToolPath ParameterType="System.String" Required="true" /> |
| 11 | + <LocalRoslynFolderName ParameterType="System.String" Required="true" /> |
| 12 | + <LocalLatestRoslynFolderName ParameterType="System.String" Required="true" /> |
| 13 | + <ReferenceRoslynNupkgVersion ParameterType="System.String" Required="true" /> |
| 14 | + <ReferenceLatestRoslynNupkgVersion ParameterType="System.String" Required="true" /> |
| 15 | + </ParameterGroup> |
| 16 | + <Task> |
| 17 | + <Reference Include="System" /> |
| 18 | + <Reference Include="System.IO.Compression.FileSystem" /> |
| 19 | + <Using Namespace="System.IO" /> |
| 20 | + <Using Namespace="System.IO.Compression" /> |
| 21 | + <Using Namespace="System.Net" /> |
| 22 | + <Code Type="Fragment" Language="cs"> |
| 23 | + <![CDATA[ |
| 24 | + try |
| 25 | + { |
| 26 | + using (var wc = new WebClient()) |
| 27 | + { |
| 28 | + var roslynNugetBaseUri = "https://api.nuget.org/packages/microsoft.net.compilers.{0}.nupkg"; |
| 29 | + var roslynPackageName = "microsoft.net.compilers.{0}.nupkg"; |
| 30 | +
|
| 31 | + var targetFilePath = Path.Combine(Path.GetTempPath(), string.Format(roslynPackageName, ReferenceRoslynNupkgVersion)); |
| 32 | + var targetExtractPath = Path.Combine(Path.GetTempPath(), LocalRoslynFolderName); |
| 33 | + var targetPath = Path.Combine(NupkgToolPath, LocalRoslynFolderName); |
| 34 | + if (Directory.Exists(targetExtractPath)) |
| 35 | + { |
| 36 | + Directory.Delete(targetExtractPath, true); |
| 37 | + } |
| 38 | + if (Directory.Exists(targetPath)) |
| 39 | + { |
| 40 | + Directory.Delete(targetPath, true); |
| 41 | + } |
| 42 | +
|
| 43 | + wc.DownloadFile(string.Format(roslynNugetBaseUri, ReferenceRoslynNupkgVersion), targetFilePath); |
| 44 | + ZipFile.ExtractToDirectory(targetFilePath, targetExtractPath); |
| 45 | + Directory.CreateDirectory(targetPath); |
| 46 | + foreach(var file in Directory.GetFiles(Path.Combine(targetExtractPath, "tools"))){ |
| 47 | + var fi = new FileInfo(file); |
| 48 | + File.Copy(file, Path.Combine(targetPath, fi.Name)); |
| 49 | + } |
| 50 | +
|
| 51 | + targetFilePath = Path.Combine(Path.GetTempPath(), string.Format(roslynPackageName, ReferenceLatestRoslynNupkgVersion)); |
| 52 | + targetExtractPath = Path.Combine(Path.GetTempPath(), LocalLatestRoslynFolderName); |
| 53 | + targetPath = Path.Combine(NupkgToolPath, LocalLatestRoslynFolderName); |
| 54 | + if (Directory.Exists(targetExtractPath)) |
| 55 | + { |
| 56 | + Directory.Delete(targetExtractPath, true); |
| 57 | + } |
| 58 | + if (Directory.Exists(targetPath)) |
| 59 | + { |
| 60 | + Directory.Delete(targetPath, true); |
| 61 | + } |
| 62 | +
|
| 63 | + wc.DownloadFile(string.Format(roslynNugetBaseUri, ReferenceLatestRoslynNupkgVersion), targetFilePath); |
| 64 | + ZipFile.ExtractToDirectory(targetFilePath, targetExtractPath); |
| 65 | + Directory.CreateDirectory(targetPath); |
| 66 | + foreach (var file in Directory.GetFiles(Path.Combine(targetExtractPath, "tools"))) |
| 67 | + { |
| 68 | + var fi = new FileInfo(file); |
| 69 | + File.Copy(file, Path.Combine(targetPath, fi.Name)); |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + catch (Exception ex) |
| 74 | + { |
| 75 | + Log.LogErrorFromException(ex); |
| 76 | + } |
| 77 | + return true; |
| 78 | + ]]> |
| 79 | + </Code> |
| 80 | + </Task> |
| 81 | + </UsingTask> |
18 | 82 | </Project> |
0 commit comments