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

Commit fd3cd98

Browse files
allow CodeFormatter to run on Mono
1 parent 313ab9f commit fd3cd98

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,6 @@ Icon
235235
Network Trash Folder
236236
Temporary Items
237237
.apdisk
238+
239+
# Local msbuild copy to run on Mono
240+
src/ExternalApis/

init-tools.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
SRC="src"
4+
EXTERNAL_APIS_DIR="$SRC/ExternalApis"
5+
#see https://github.com/mono/msbuild/blob/xplat-c9/cibuild.sh
6+
MSBUILD_DOWNLOAD_URL="https://github.com/radical/msbuild/releases/download/v0.03/mono_msbuild_d25dd923839404bd64cc63f420e75acf96fc75c4.zip"
7+
MSBUILD_ZIP="$EXTERNAL_APIS_DIR/msbuild.zip"
8+
MSBUILD_EXE="$EXTERNAL_APIS_DIR/MSBuild/msbuild.exe"
9+
10+
downloadMSBuildForMono()
11+
{
12+
if [ ! -e "$MSBUILD_EXE" ]
13+
then
14+
mkdir -p $EXTERNAL_APIS_DIR
15+
16+
echo "** Downloading MSBUILD from $MSBUILD_DOWNLOAD_URL"
17+
curl -sL -o $MSBUILD_ZIP "$MSBUILD_DOWNLOAD_URL"
18+
19+
unzip -q $MSBUILD_ZIP -d $EXTERNAL_APIS_DIR
20+
find "$EXTERNAL_APIS_DIR/msbuild" -name "*.exe" -exec chmod "+x" '{}' ';'
21+
rm $MSBUILD_ZIP
22+
fi
23+
}
24+
25+
downloadMSBuildForMono

src/CodeFormatter/App.config

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</startup>
66
<runtime>
77
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<probing privatePath="./msbuild" />
89
<dependentAssembly>
910
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
1011
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />

src/CodeFormatter/CodeFormatter.csproj

+18
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@
105105
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
106106
</ItemGroup>
107107
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
108+
<Target Name="CopyMSBuildForMono"
109+
AfterTargets="AfterBuild"
110+
Condition=" '$(OS)' == 'Unix' ">
111+
<ItemGroup>
112+
<_CopyItems Include="..\ExternalApis\msbuild\*.*" />
113+
</ItemGroup>
114+
<Copy
115+
SourceFiles="@(_CopyItems)"
116+
DestinationFolder="$(TargetDir)\msbuild"
117+
/>
118+
</Target>
119+
<Target Name="AfterClean"
120+
Condition=" '$(OS)' == 'Unix' ">
121+
<ItemGroup>
122+
<LocalMonoMSBuild Include="$(TargetDir)\msbuild" />
123+
</ItemGroup>
124+
<RemoveDir Directories="@(LocalMonoMSBuild)" />
125+
</Target>
108126
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
109127
Other similar extension points exist, see Microsoft.Common.targets.
110128
<Target Name="BeforeBuild">

0 commit comments

Comments
 (0)