├── .editorconfig ├── .gitattributes ├── .gitignore ├── .gitmodules ├── LICENSE ├── NuGet.Config ├── README.md ├── VERSION ├── Xamarin.Windows.props ├── Xamarin.Windows.sln ├── Xamarin.Windows.sln.DotSettings ├── build.cmd ├── build.proj ├── build.sh ├── fetch-build-tools.cmd ├── mk-vs-experimental-links.bat ├── msbuild ├── CopyReferenceAssembliesFromMonoDevRoot.proj ├── CreateToolchain.proj ├── FrameworkList.xml ├── GenericNativeWindowsExecutable.vcxproj ├── TestProjects │ ├── ClassLibrary │ │ ├── ClassLibrary.csproj │ │ ├── LibClass.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ └── ConsoleApp │ │ ├── ConsoleApp.csproj │ │ ├── ConsoleApp.exe.config │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── a.foo │ │ ├── b.foo │ │ ├── dir │ │ ├── c.foo │ │ └── d.bar │ │ └── mscorlib.dll.config ├── Xamarin.Windows.Build.Tasks │ ├── LauncherTemplate.c │ ├── Platform.c │ ├── Platform.h │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── Tasks │ │ ├── Aot.cs │ │ ├── ConvertDebuggingFiles.cs │ │ ├── ExtractItems.cs │ │ ├── GenerateBundledAssemblies.cs │ │ ├── GenerateLauncher.cs │ │ └── ResolveAssemblies.cs │ ├── Utilities │ │ ├── DirectoryAssemblyResolver.cs │ │ ├── MSBuildExtensions.cs │ │ └── Symbols.cs │ └── Xamarin.Windows.Build.Tasks.csproj ├── Xamarin.Windows.Build.Tests │ ├── ExtractItemsTestExpected1.xml │ ├── ExtractItemsTestExpected2.xml │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── TargetTests.cs │ ├── TestBase.cs │ └── Xamarin.Windows.Build.Tests.csproj ├── Xamarin.Windows.CSharp.targets └── Xamarin.Windows.Common.targets └── vs ├── Xamarin.Windows.Properties ├── Clide │ └── JoinableLazy.cs ├── Guids.cs ├── Key.snk ├── OptionsPage.cs ├── OptionsPageView.xaml ├── OptionsPageView.xaml.cs ├── OptionsPageViewModel.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── VisualStudio.Properties │ ├── BasePropertyPage.cs │ ├── BuildPropertyStorage.cs │ ├── Constants.cs │ ├── Extensions │ │ └── IVsHierarchyExtensions.cs │ ├── IItemsProvider.cs │ ├── IPropertyStorage.cs │ ├── InMemoryPropertyStorage.cs │ ├── ItemViewModel.cs │ └── ViewModelBase.cs ├── VsPackage.cs ├── Xamarin.Windows.Properties.csproj └── source.extension.vsixmanifest ├── Xamarin.Windows.VisualStudio.Templates ├── CSharp │ ├── ConsoleApplication │ │ ├── AssemblyInfo.cs │ │ ├── CSharpConsoleApplication.csproj │ │ ├── CSharpConsoleApplication.ico │ │ ├── CSharpConsoleApplication.vstemplate │ │ └── Program.cs │ └── StaticLibrary │ │ ├── AssemblyInfo.cs │ │ ├── CSharpStaticLibrary.csproj │ │ ├── CSharpStaticLibrary.ico │ │ ├── CSharpStaticLibrary.vstemplate │ │ └── Class1.cs └── Xamarin.Windows.VisualStudio.Templates.csproj └── Xamarin.Windows.VisualStudio.Vsix ├── Key.snk ├── MSBuild.items ├── ProjectExtensions.cs ├── ProjectPackageGuids.cs ├── Properties └── AssemblyInfo.cs ├── ReferenceAssemblies.items ├── Xamarin.Windows.VisualStudio.Vsix.csproj ├── XamarinWindowsConstants.cs ├── XamarinWindowsDebugLauncher.cs ├── XamarinWindowsDebuggableConfig.cs ├── XamarinWindowsDebuggerSession.cs ├── XamarinWindowsFlavoredProject.cs ├── XamarinWindowsPackage.cs ├── XamarinWindowsProject.cs ├── XamarinWindowsStartInfo.cs └── source.extension.vsixmanifest /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sln text eol=crlf 2 | *.csproj text eol=crlf 3 | *.vcxproj text eol=crlf 4 | 5 | * text eol=lf 6 | 7 | *.png binary 8 | *.jpg binary 9 | *.ico binary 10 | *.rtf binary 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.userprefs 2 | *.Override.props 3 | Configuration.OperatingSystem.props 4 | msfinal.pub 5 | packages/ 6 | build/ 7 | .DS_Store 8 | .nuget 9 | .vs/ 10 | /buildtools/ 11 | /external/mono/ 12 | GitInfo.cache 13 | tests/TestResult*.xml 14 | /tmp/ 15 | 16 | # Visual Studio / MonoDevelop 17 | *.[Oo]bj 18 | *.exe 19 | *.dll 20 | *.pdb 21 | *.user 22 | *.aps 23 | *.pch 24 | *.vspscc 25 | *.vssscc 26 | *_i.c 27 | *_p.c 28 | *.ncb 29 | *.suo 30 | *.tlb 31 | *.tlh 32 | *.bak 33 | *.ilk 34 | *.log 35 | *.lib 36 | *.sbr 37 | *.sdf 38 | *.opensdf 39 | *.resources 40 | *.res 41 | *.lst 42 | ipch/ 43 | obj/ 44 | [Bb]in 45 | [Dd]ebug*/ 46 | [Rr]elease*/ 47 | Ankh.NoLoad 48 | *.gpState 49 | *.VC.db 50 | *.VC.opendb -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/linker"] 2 | path = external/linker 3 | url = https://github.com/mono/linker.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) .NET Foundation Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Xamarin Windows 2 | =============== 3 | 4 | Goals for this project: 5 | 6 | * Provide MSBuild and VS tooling for building, launching, debugging Windows 7 | x64 full AOT binaries. 8 | * Provide reusable MSBuild tasks and targets for other platforms which also 9 | compile down to full AOT binaries, e.g. Xbox One and PS4. 10 | 11 | # Build instructions 12 | 13 | In order to build this project you'll need: 14 | 15 | * **Git for Windows** 16 | * **Visual Studio 2017** 17 | * **Clang2** 18 | * **Windows 8.1 SDK and all Windows 10 SDKs** 19 | You'll find Clang2 and the Windows SDKs in the Visual Studio 2017 setup, under the "Individual components" tab. 20 | * **Mono for Windows** release 21 | 22 | 23 | **NOTE**: Windows has a problem with long (> 260 characters) paths. To avoid 24 | any issues related to this limitation when building this project you should 25 | make sure to checkout this repository in a shallow path on your system. E.g. 26 | to `C:\xw`: 27 | 28 | ``` 29 | cd C:\ 30 | git clone git@github.com:xamarin/xamarin-windows.git xw 31 | cd xw 32 | ``` 33 | 34 | ## Build using build.cmd 35 | 36 | To build the project just run the `build.cmd` script. 37 | 38 | ## Manual build 39 | 40 | When developing on this project you may prefer to run the individual steps 41 | carried out by `build.cmd` manually. 42 | 43 | For a manual build you will need Cygwin installed. Consult the [Compiling Mono 44 | on Windows](http://www.mono-project.com/docs/compiling-mono/windows/) 45 | documentation for more details on the prerequisites. 46 | 47 | The commands below asumes Visual Studio 2017 **Enterprise** is installed. This is **not required**. 48 | Adjust the paths to Visual Studio according to the specific flavor of your Visual Studio 2017 installation. 49 | 50 | ### Fetch submodules 51 | 52 | ``` 53 | cd C:\xw 54 | git submodule update --init --recursive 55 | ``` 56 | 57 | ### Build the mono winaot BCL profile 58 | 59 | By default a mono checkout is expected in `mono/external`. Create a 60 | `Xamarin.Windows.Override.props` file in the root of the `xamarin-windows` 61 | checkout with a `MonoDevRoot` property to override the path to the mono 62 | checkout. 63 | 64 | **NOTE**: A specific mono commit is expected to be checked out. Check the 65 | `MonoCommit` property in the `Xamarin.Windows.props` file. 66 | 67 | Run from within cygwin: 68 | ```bash 69 | cd path/to/mono 70 | git checkout 71 | ./autogen.sh --host=x86_64-w64-mingw32 --disable-boehm --with-runtime_preset=winaot 72 | export MONO_EXECUTABLE="`cygpath -u -a msvc\\\build\\\sgen\\\x64\\\bin\\\Release\\\mono-sgen.exe`" 73 | export VC_ROOT="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC" 74 | export CLANG2_VERSION=$(sed -n 1p "$VC_ROOT/Auxiliary/Build/Microsoft.ClangC2Version.default.txt" | sed 's/\s//g') 75 | export VCTOOLS_VERSION=$(sed -n 1p "$VC_ROOT/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | sed 's/\s//g') 76 | export PATH="$VC_ROOT/Tools/ClangC2/$CLANG2_VERSION/bin/HostX64":"$VC_ROOT/Tools/MSVC/$VCTOOLS_VERSION/bin/HostX64/x64":$PATH 77 | /cygdrive/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe /p:PlatformToolset=v140 /p:Platform=x64 /p:Configuration=Release /p:MONO_TARGET_GC=sgen msvc/mono.sln 78 | make -C mcs/ 79 | ``` 80 | 81 | ### Copy reference assemblies to the build folder 82 | 83 | The VS extension relies on the Mono BCL to be present in the 84 | `build/ReferenceAssemblies/` folder. Run the following to copy the relevant 85 | files: 86 | ``` 87 | cd C:\xw 88 | "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" msbuild\CopyReferenceAssembliesFromMonoDevRoot.proj 89 | ``` 90 | 91 | ### Create the MSBuild toolchain in the build folder 92 | 93 | The VS extension relies on the MSBuild files and the mono installation being 94 | installed in `build/MSBuild/`. Run the following to copy the relevant files: 95 | ``` 96 | cd C:\xw 97 | "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" msbuild\CreateToolchain.proj 98 | ``` 99 | 100 | ### Build the MSBuild tasks and VS extension 101 | 102 | You should now be able to open the `Xamarin.Windows.sln` solution and build 103 | it. 104 | 105 | 106 | ### Debugging the VS extension 107 | 108 | **NOTE!** For now, Xamarin needs to be installed in Visual Studio. Make sure 109 | to enable that in the Visual Studio setup. 110 | 111 | At this time VS extensions with embedded MSBuild files or Reference Assemblies 112 | are not properly deployed to the experimental instance. We need to setup 113 | symbolic linkes to make sure the VS process correctly loads the MSBuild and 114 | Reference Assemblies from the `$MSBuild` and `$ReferenceAssemblies` folders 115 | located inside the extension folder in the experimental instance folder. The 116 | `mk-vs-experimental-links.bat` script in the root of the source tree creates 117 | these links (must be run as Administrator): 118 | 119 | ``` 120 | cd C:\xw 121 | mk-vs-experimental-links.bat 122 | ``` 123 | 124 | It should now be possible to debug the extension in VS. **NOTE!** These links 125 | have to be recreated whenever the VS extension's verison number changes. The 126 | version number is based on the number of commits so make sure to run the 127 | script after new files have been committed or pulled. 128 | 129 | 130 | # Converting an ordinary C# project to a Xamarin.Windows project 131 | 132 | Edit the `.csproj` file to make it a Xamarin.Windows project. The line 133 | 134 | ```xml 135 | 136 | ``` 137 | 138 | must be changed to 139 | 140 | ```xml 141 | 142 | ``` 143 | 144 | Then add the line 145 | 146 | ```xml 147 | {8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 148 | ``` 149 | 150 | to the first `` section in the `.csproj` file. 151 | 152 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.0.0 2 | -------------------------------------------------------------------------------- /Xamarin.Windows.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Xamarin.Windows.props 6 | Xamarin.Windows.Override.props 7 | $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., $(PropsFileName))) 8 | 9 | 10 | 11 | 12 | 13 | 14 | $(MSBuildThisFileDirectory)external\mono 15 | "C:\Program Files\Git\bin\git.exe" 16 | "C:\Program Files (x86)\Git\bin\git.exe" 17 | C:\msysgit\bin\git.exe 18 | C:\cygwin\bin\git.exe 19 | git.exe 20 | $([System.IO.Path]::GetFullPath ('$(MonoDevRoot)')) 21 | 0ed43bba73b2e0306bda0ae90d1f422315bb82e1 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Xamarin.Windows.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | HINT 3 | Required 4 | Required 5 | Required 6 | Required 7 | END_OF_LINE 8 | END_OF_LINE 9 | END_OF_LINE 10 | END_OF_LINE 11 | END_OF_LINE 12 | False 13 | False 14 | False 15 | True 16 | 17 | True 18 | 1 19 | True 20 | True 21 | True -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal ENABLEDELAYEDEXPANSION 4 | 5 | set BASE_DIR=%~dp0 6 | set BUILD_TOOLS_DIR=%BASE_DIR%\buildtools 7 | set CYGWIN_DIR=%BUILD_TOOLS_DIR%\cygwin 8 | set BASH_EXE="%CYGWIN_DIR%\bin\bash.exe" 9 | 10 | pushd %BASE_DIR% 11 | 12 | call fetch-build-tools.cmd 13 | 14 | set PATH=%PATH%;%CYGWIN_DIR%\bin 15 | set SHELLOPTS=igncr 16 | %BASH_EXE% --login -c "`cygpath -u '%BASE_DIR%'`/build.sh" 2>&1 17 | set RESULT=!ERRORLEVEL! 18 | 19 | popd 20 | 21 | if not %RESULT% == 0 ( 22 | echo "Build failed with code %RESULT%!" 1>&2 23 | ) 24 | exit /b %RESULT% 25 | 26 | endlocal 27 | -------------------------------------------------------------------------------- /build.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | high 5 | VERSION 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | $(GitSemVerMajor) 15 | $(GitSemVerMinor) 16 | $(GitBaseVersion.Substring($(GitBaseVersion.LastIndexOf('.'))).TrimStart('.')) 17 | $(GitCommits) 18 | $(GitCommit) 19 | $(GitSha) 20 | $(XamarinWindowsMajor).$(XamarinWindowsMinor).$(XamarinWindowsBuild).$(XamarinWindowsRevision) 21 | $(XamarinWindowsVersion)_$(XamarinWindowsCommit) 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /fetch-build-tools.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal ENABLEDELAYEDEXPANSION 4 | 5 | set BASE_DIR=%~dp0 6 | set BUILD_TOOLS_DIR=%BASE_DIR%\buildtools 7 | set CYGWIN_DIR=%BUILD_TOOLS_DIR%\cygwin 8 | set CYGWIN_SETUP_EXE="%CYGWIN_DIR%\setup-x86_64.exe" 9 | set CYGWIN_MIRROR=http://www.mirrorservice.org/sites/sourceware.org/pub/cygwin/ 10 | set PACKAGES=autoconf,automake,make,libtool,gcc-core,gcc-g++,mingw64-x86_64-runtime,mingw64-x86_64-gcc-g++,wget,zip 11 | set BASH_EXE="%CYGWIN_DIR%\bin\bash.exe" 12 | set NUGET_EXE="%BUILD_TOOLS_DIR%\nuget.exe" 13 | set PATH=%CYGWIN_DIR%\bin;%PATH% 14 | 15 | pushd %BASE_DIR% 16 | 17 | if not exist %CYGWIN_DIR% ( 18 | md %CYGWIN_DIR% 19 | ) 20 | 21 | if not exist %CYGWIN_SETUP_EXE% ( 22 | echo Downloading %CYGWIN_SETUP_EXE%... 23 | powershell -Command "(new-object System.Net.WebClient).Downloadfile('https://cygwin.com/setup-x86_64.exe', '%CYGWIN_SETUP_EXE%')" 24 | echo Download finished. 25 | ) 26 | 27 | if not exist %BASH_EXE% ( 28 | echo Cygwin not installed. Running cygwin setup... 29 | %CYGWIN_SETUP_EXE% -s %CYGWIN_MIRROR% -n --no-admin -R %CYGWIN_DIR% -l %CYGWIN_DIR%\packages -q -P %PACKAGES% 30 | :: Make sure the home folder for the current user is created 31 | %BASH_EXE% --login -c "exit" 32 | echo Setup finished. 33 | ) else ( 34 | :: Check whether all required packages are installed. If not we need to rerun the cygwin setup. 35 | %BASH_EXE% -c "cygcheck -c -d | tail -n +3 | cut -d' ' -f1 | sort" > "%CYGWIN_DIR%"\installed_packages 36 | %BASH_EXE% -c "echo '%PACKAGES%' | sed 's/,/\n/g' | sort" > "%CYGWIN_DIR%"\required_packages 37 | %BASH_EXE% -c "if [[ `comm -23 buildtools/cygwin/required_packages buildtools/cygwin/installed_packages` ]]; then exit 1; else exit 0; fi" 38 | if ERRORLEVEL 1 ( 39 | echo Outdated cygwin install. Running cygwin setup... 40 | %CYGWIN_SETUP_EXE% -n --no-admin -R %CYGWIN_DIR% -l %CYGWIN_DIR%\packages -q -P %PACKAGES% 41 | echo Setup finished. 42 | ) 43 | ) 44 | 45 | if not exist %NUGET_EXE% ( 46 | echo Downloading %NUGET_EXE%... 47 | powershell -Command "(new-object System.Net.WebClient).Downloadfile('https://dist.nuget.org/win-x86-commandline/v4.1.0/nuget.exe', '%NUGET_EXE%')" 48 | echo Download finished. 49 | ) 50 | 51 | popd 52 | 53 | endlocal 54 | -------------------------------------------------------------------------------- /mk-vs-experimental-links.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal ENABLEDELAYEDEXPANSION 4 | 5 | set VS_VERSION=15 6 | set EXT_NAME=Xamarin SDK for Windows 7 | set MSBUILD_SUB_DIR=Xamarin\Windows 8 | set REF_ASSEMBLIES_SUB_DIR=Xamarin.Windows 9 | set VSWHERE=C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe 10 | set VS_APPDATA_DIR=%USERPROFILE%\AppData\Local\Microsoft\VisualStudio 11 | 12 | if not exist "%VSWHERE%" ( 13 | echo vswhere.exe could not be found. Is Visual Studio 2017 installed? 14 | exit /B 1 15 | ) 16 | 17 | for /F "tokens=* USEBACKQ" %%F IN (`"%VSWHERE%" -property installationPath`) do ( 18 | set VSINSTALLPATH=%%F 19 | ) 20 | if not exist "%VSINSTALLPATH%" ( 21 | echo No Visual Studio installation found 22 | exit /B 1 23 | ) 24 | echo Found Visual Studio installation: '%VSINSTALLPATH%' 25 | 26 | for /D %%F IN (%VS_APPDATA_DIR%\%VS_VERSION%*Exp) do ( 27 | set EXP_DIR=%%F 28 | goto exp_dir_found 29 | ) 30 | echo No experimental instance dir found in '%VS_APPDATA_DIR%' 31 | exit /B 1 32 | 33 | :exp_dir_found 34 | echo Found experimental instance dir '%EXP_DIR%' 35 | 36 | set EXT_BASE_DIR=%EXP_DIR%\Extensions\Xamarin\%EXT_NAME% 37 | 38 | for /D %%F IN ("%EXT_BASE_DIR%"\*) do ( 39 | if exist %%F\extension.vsixmanifest ( 40 | set EXT_DIR=%%F 41 | goto version_found 42 | ) 43 | ) 44 | echo No '%EXT_NAME%' extension found in '%EXT_BASE_DIR%' 45 | exit /B 1 46 | 47 | :version_found 48 | echo Found extension dir '%EXT_DIR%' 49 | 50 | set TARGET=%EXT_DIR%\$MSBuild\%MSBUILD_SUB_DIR% 51 | set LINK=%VSINSTALLPATH%\MSBuild\%MSBUILD_SUB_DIR% 52 | echo Linking '%LINK%' to '%TARGET%' 53 | if exist "%LINK%" ( 54 | rmdir "%LINK%" 55 | ) 56 | mklink /D "%LINK%" "%TARGET%" 57 | 58 | set TARGET=%EXT_DIR%\$ReferenceAssemblies\Microsoft\Framework\%REF_ASSEMBLIES_SUB_DIR% 59 | set LINK=%VSINSTALLPATH%\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\%REF_ASSEMBLIES_SUB_DIR% 60 | echo Linking '%LINK%' to '%TARGET%' 61 | if exist "%LINK%" ( 62 | rmdir "%LINK%" 63 | ) 64 | mklink /D "%LINK%" "%TARGET%" 65 | 66 | endlocal 67 | -------------------------------------------------------------------------------- /msbuild/CopyReferenceAssembliesFromMonoDevRoot.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Xamarin.Windows 8 | v1.0 9 | $(MSBuildThisFileDirectory)..\build\ReferenceAssemblies 10 | winaot 11 | $(MSBuildThisFileDirectory)\FrameworkList.xml 12 | <_TargetPath>$(ReferenceAssembliesInstallPath)\$(TargetFrameworkName)\$(TargetFrameworkVersion) 13 | <_BclSourcePath>$(MonoDevRoot)\mcs\class\lib\$(BclProfile) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 34 | 36 | 38 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /msbuild/CreateToolchain.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | $(MSBuildThisFileDirectory)..\build\MSBuild 8 | 9 | 10 | 11 | 12 | 13 | $(MonoDevRoot)\msvc\build\toolchains 14 | PlatformToolset=v140;MONO_TARGET_GC=sgen;MONO_BUILD_DIR_PREFIX=$(ToolchainsBuildPath)\ 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | <_Files Include="mono-sgen.exe;mono-2.0-sgen.dll;mono-sgen.pdb;mono-2.0-sgen.pdb;MonoPosixHelper.dll;MonoPosixHelper.pdb"> 27 | %(Configurations.Identity) 28 | bin 29 | 30 | <_Files Include="eglib.lib;libgc.lib;libgcmonosgen.lib;libmonoruntime-sgen.lib;libmono-static-sgen.lib;libmonoutils.lib;mono-2.0-sgen.lib;MonoPosixHelper.lib"> 31 | %(Configurations.Identity) 32 | lib 33 | 34 | 35 | %(Platforms.Identity) 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /msbuild/FrameworkList.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /msbuild/GenericNativeWindowsExecutable.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Debug 7 | Win32 8 | 9 | 10 | Release 11 | Win32 12 | 13 | 14 | Debug 15 | x64 16 | 17 | 18 | Release 19 | x64 20 | 21 | 22 | 23 | Win32Proj 24 | 8.1 25 | 26 | 27 | 28 | Application 29 | true 30 | v141 31 | Unicode 32 | 33 | 34 | Application 35 | false 36 | v141 37 | true 38 | Unicode 39 | 40 | 41 | Application 42 | true 43 | v141 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v141 50 | true 51 | Unicode 52 | 53 | 54 | 55 | true 56 | 57 | 58 | false 59 | 60 | 61 | 62 | Level3 63 | Disabled 64 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 65 | 66 | 67 | Console 68 | true 69 | 70 | 71 | 72 | 73 | Level3 74 | Disabled 75 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 76 | 77 | 78 | Console 79 | true 80 | 81 | 82 | 83 | 84 | MaxSpeed 85 | true 86 | true 87 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 88 | 89 | 90 | Console 91 | true 92 | true 93 | 94 | 95 | 96 | 97 | MaxSpeed 98 | true 99 | true 100 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 101 | 102 | 103 | Console 104 | true 105 | true 106 | 107 | 108 | 109 | 110 | 111 | %(AdditionalDependencies);$(XWAdditionalDependencies) 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /msbuild/TestProjects/ClassLibrary/ClassLibrary.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E18716AC-C8E0-4A90-90B2-CED6F9C17EE8} 8 | Library 9 | Properties 10 | ClassLibrary 11 | ClassLibrary 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | -------------------------------------------------------------------------------- /msbuild/TestProjects/ClassLibrary/LibClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClassLibrary 8 | { 9 | public class LibClass 10 | { 11 | public static void SayHello() 12 | { 13 | Console.WriteLine($"Hello from {typeof(LibClass).Assembly.GetName().Name}!"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /msbuild/TestProjects/ClassLibrary/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ClassLibrary")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ClassLibrary")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e18716ac-c8e0-4a90-90b2-ced6f9c17ee8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/ConsoleApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D13393BF-7B03-49D1-92B4-A48D74EE2FEC} 8 | Exe 9 | Properties 10 | ConsoleApp 11 | ConsoleApp 12 | v1.0 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | West 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | West 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | {e18716ac-c8e0-4a90-90b2-ced6f9c17ee8} 47 | ClassLibrary 48 | False 49 | 50 | 51 | 52 | 53 | PreserveNewest 54 | 55 | 56 | PreserveNewest 57 | 58 | 59 | 60 | 61 | 63 | BeforeBuild;CoreBuild;AfterBuild 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | DefaultValue 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | ExplicitValue 84 | 85 | 86 | 87 | assets\foobar.txt 88 | NotEmpty 89 | Empty 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 104 | -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/ConsoleApp.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace ConsoleApp 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | // Reference something in System.dll to make ResolveAssemblies 11 | // include it in the resolved framework assemblies. 12 | Console.WriteLine($"Hello from {Process.GetCurrentProcess().MainModule.FileName}!"); 13 | // Likewise we need to reference something in ClassLibrary. 14 | ClassLibrary.LibClass.SayHello(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AotTest1")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AotTest1")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d13393bf-7b03-49d1-92b4-a48d74ee2fec")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/a.foo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/msbuild/TestProjects/ConsoleApp/a.foo -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/b.foo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/msbuild/TestProjects/ConsoleApp/b.foo -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/dir/c.foo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/msbuild/TestProjects/ConsoleApp/dir/c.foo -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/dir/d.bar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/msbuild/TestProjects/ConsoleApp/dir/d.bar -------------------------------------------------------------------------------- /msbuild/TestProjects/ConsoleApp/mscorlib.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/LauncherTemplate.c: -------------------------------------------------------------------------------- 1 | #include "platform.h" 2 | #include 3 | #include 4 | 5 | // ${Defines} 6 | 7 | // ${AOTModules} 8 | // ${BundledAssemblies} 9 | // ${BundledAssemblyConfigs} 10 | // ${BundledAssemblyCleanups} 11 | 12 | #ifndef ROOT_DOMAIN_NAME 13 | #define ROOT_DOMAIN_NAME "Mono" 14 | #endif 15 | 16 | #ifndef RUNTIME_VERSION 17 | #define RUNTIME_VERSION NULL 18 | #endif 19 | 20 | int mono_launcher_initialize (int argc, char* argv[]) 21 | { 22 | return mono_launcher_platform_initialize (ROOT_DOMAIN_NAME, RUNTIME_VERSION, 23 | argc, argv, 24 | GET_AOT_MODULES, GET_BUNDLED_ASSEMBLIES, 25 | GET_BUNDLED_ASSEMBLY_CONFIGS, GET_BUNDLED_ASSEMBLY_CLEANUPS); 26 | } 27 | 28 | int mono_launcher_exec (const char *main_assembly_name, int argc, char* argv[]) 29 | { 30 | return mono_launcher_platform_exec (main_assembly_name, argc, argv); 31 | } 32 | 33 | void mono_launcher_terminate (void) 34 | { 35 | mono_launcher_platform_terminate (); 36 | } 37 | 38 | #ifndef SKIP_MAIN 39 | 40 | static char **mono_options = NULL; 41 | 42 | static int count_mono_options_args (void) 43 | { 44 | const char *e = getenv ("MONO_BUNDLED_OPTIONS"); 45 | const char *p, *q; 46 | int i, n; 47 | 48 | if (e == NULL) 49 | return 0; 50 | 51 | /* Don't bother with any quoting here. It is unlikely one would 52 | * want to pass options containing spaces anyway. 53 | */ 54 | 55 | p = e; 56 | n = 1; 57 | while ((q = strchr (p, ' ')) != NULL) { 58 | if (q != p) n++; 59 | p = q + 1; 60 | } 61 | 62 | mono_options = malloc (sizeof (char *) * (n + 1)); 63 | p = e; 64 | i = 0; 65 | while ((q = strchr (p, ' ')) != NULL) { 66 | if (q != p) { 67 | mono_options[i] = malloc ((q - p) + 1); 68 | memcpy (mono_options[i], p, q - p); 69 | mono_options[i][q - p] = '\0'; 70 | i++; 71 | } 72 | p = q + 1; 73 | } 74 | mono_options[i++] = strdup (p); 75 | mono_options[i] = NULL; 76 | 77 | return n; 78 | } 79 | 80 | 81 | int main (int argc, char* argv[]) 82 | { 83 | char **newargs; 84 | int i, k = 0; 85 | int result = -1; 86 | 87 | newargs = (char **) malloc (sizeof (char *) * (argc + 2 + count_mono_options_args ())); 88 | 89 | newargs [k++] = argv [0]; 90 | 91 | if (mono_options != NULL) { 92 | i = 0; 93 | while (mono_options[i] != NULL) 94 | newargs[k++] = mono_options[i++]; 95 | } 96 | 97 | newargs [k++] = "${MainAssemblyName}"; 98 | 99 | for (i = 1; i < argc; i++) { 100 | newargs [k++] = argv [i]; 101 | } 102 | newargs [k] = NULL; 103 | 104 | if (mono_launcher_initialize (k, newargs)) 105 | { 106 | result = mono_main (k, newargs); 107 | mono_launcher_terminate (); 108 | } 109 | 110 | return result; 111 | } 112 | 113 | #endif -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Platform.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | #include 4 | 5 | #include "platform.h" 6 | 7 | #define TRUE 1 8 | #define FALSE 0 9 | 10 | typedef int32_t gboolean; 11 | typedef struct _MonoAssembly MonoAssembly; 12 | typedef struct _MonoDomain MonoDomain; 13 | typedef enum { MONO_IMAGE_OK } MonoImageOpenStatus; 14 | 15 | extern void mono_jit_set_aot_only (gboolean val); 16 | extern void mono_aot_register_module (void *aot_info); 17 | extern void mono_register_bundled_assemblies (const MonoBundledAssembly **assemblies); 18 | extern void mono_register_config_for_assembly (const char* assembly_name, const char* config_xml); 19 | extern MonoDomain *mono_jit_init_version (const char *domain_name, const char *runtime_version); 20 | extern int mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]); 21 | extern MonoAssembly* mono_assembly_open (const char *filename, MonoImageOpenStatus *status); 22 | extern MonoDomain *mono_domain_get (void); 23 | extern void mono_jit_cleanup (MonoDomain *domain); 24 | 25 | static int initialized = 0; 26 | static BundledAssemblyCleanup **_cleanups; 27 | 28 | int mono_launcher_platform_initialize ( 29 | const char *root_domain_name, 30 | const char *runtime_version, 31 | int argc, char* argv[], 32 | void **aot_modules, 33 | MonoBundledAssembly **bundled_assemblies, 34 | MonoBundledAssemblyConfig **configs, 35 | BundledAssemblyCleanup **cleanups) 36 | { 37 | if (initialized) 38 | return 1; 39 | 40 | _cleanups = cleanups; 41 | 42 | for (int i = 0; aot_modules[i]; i++) 43 | mono_aot_register_module (aot_modules[i]); 44 | for (int i = 0; configs[i]; i++) { 45 | if (configs[i]->data) 46 | mono_register_config_for_assembly (configs[i]->name, configs[i]->data); 47 | } 48 | if (bundled_assemblies && bundled_assemblies[0]) 49 | mono_register_bundled_assemblies (bundled_assemblies); 50 | 51 | mono_jit_set_aot_only (TRUE); 52 | 53 | initialized = 1; 54 | return 1; 55 | } 56 | 57 | int mono_launcher_platform_exec (const char *main_assembly_name, int argc, char* argv[]) 58 | { 59 | if (!initialized) 60 | return -1; 61 | 62 | MonoAssembly *assembly = mono_assembly_open (main_assembly_name, NULL); 63 | if (!assembly) 64 | return -1; 65 | return mono_jit_exec (mono_domain_get (), assembly, argc, argv); 66 | } 67 | 68 | void mono_launcher_platform_terminate () 69 | { 70 | if (initialized) 71 | { 72 | mono_jit_cleanup (mono_domain_get ()); 73 | 74 | for (int i = 0; _cleanups[i]; i++) { 75 | _cleanups[i] (); 76 | } 77 | initialized = 0; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Platform.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | int mono_main (int argc, char* argv[]); 4 | 5 | #include 6 | 7 | typedef struct { 8 | const char *name; 9 | const unsigned char *data; 10 | const unsigned int size; 11 | } MonoBundledAssembly; 12 | 13 | typedef struct { 14 | const char *name; 15 | const char *data; 16 | } MonoBundledAssemblyConfig; 17 | 18 | typedef MonoBundledAssembly *(BundledAssemblyGetter)(void); 19 | typedef MonoBundledAssemblyConfig *(BundledAssemblyConfigGetter)(void); 20 | typedef void (BundledAssemblyCleanup) (void); 21 | 22 | #define BEGIN_DECLARE_AOT_MODULES static void *_aot_modules[] = { 23 | #define DECLARE_AOT_MODULE(symbol) NULL, 24 | #define END_DECLARE_AOT_MODULES NULL}; 25 | #define BEGIN_DEFINE_AOT_MODULES static void **_get_aot_modules(void) { int n = 0; 26 | #define DEFINE_AOT_MODULE(symbol) extern void *symbol; _aot_modules[n++] = symbol; 27 | #define END_DEFINE_AOT_MODULES return _aot_modules; } 28 | #define GET_AOT_MODULES _get_aot_modules() 29 | 30 | #define BEGIN_DECLARE_BUNDLED_ASSEMBLIES static MonoBundledAssembly *_bundled_assemblies[] = { 31 | #define DECLARE_BUNDLED_ASSEMBLY(symbol) NULL, 32 | #define END_DECLARE_BUNDLED_ASSEMBLIES NULL}; 33 | #define BEGIN_DEFINE_BUNDLED_ASSEMBLIES static MonoBundledAssembly **_get_bundled_assemblies(void) { int n = 0; 34 | #define DEFINE_BUNDLED_ASSEMBLY(symbol) extern BundledAssemblyGetter symbol; _bundled_assemblies[n++] = symbol(); 35 | #define END_DEFINE_BUNDLED_ASSEMBLIES return _bundled_assemblies; }; 36 | #define GET_BUNDLED_ASSEMBLIES _get_bundled_assemblies() 37 | 38 | #define BEGIN_DECLARE_BUNDLED_ASSEMBLY_CONFIGS static MonoBundledAssemblyConfig *_bundled_assembly_configs[] = { 39 | #define DECLARE_BUNDLED_ASSEMBLY_CONFIG(symbol) NULL, 40 | #define END_DECLARE_BUNDLED_ASSEMBLY_CONFIGS NULL}; 41 | #define BEGIN_DEFINE_BUNDLED_ASSEMBLY_CONFIGS static MonoBundledAssemblyConfig **_get_bundled_assembly_configs(void) { int n = 0; 42 | #define DEFINE_BUNDLED_ASSEMBLY_CONFIG(symbol) extern BundledAssemblyConfigGetter symbol; _bundled_assembly_configs[n++] = symbol(); 43 | #define END_DEFINE_BUNDLED_ASSEMBLY_CONFIGS return _bundled_assembly_configs; }; 44 | #define GET_BUNDLED_ASSEMBLY_CONFIGS _get_bundled_assembly_configs() 45 | 46 | #define BEGIN_DECLARE_BUNDLED_ASSEMBLY_CLEANUPS static BundledAssemblyCleanup *_bundled_assembly_cleanups[] = { 47 | #define DECLARE_BUNDLED_ASSEMBLY_CLEANUP(symbol) NULL, 48 | #define END_DECLARE_BUNDLED_ASSEMBLY_CLEANUPS NULL}; 49 | #define BEGIN_DEFINE_BUNDLED_ASSEMBLY_CLEANUPS static BundledAssemblyCleanup **_get_bundled_assembly_cleanups(void) { int n = 0; 50 | #define DEFINE_BUNDLED_ASSEMBLY_CLEANUP(symbol) extern BundledAssemblyCleanup symbol; _bundled_assembly_cleanups[n++] = symbol; 51 | #define END_DEFINE_BUNDLED_ASSEMBLY_CLEANUPS return _bundled_assembly_cleanups; }; 52 | #define GET_BUNDLED_ASSEMBLY_CLEANUPS _get_bundled_assembly_cleanups() 53 | 54 | extern int mono_launcher_platform_initialize ( 55 | const char *root_domain_name, 56 | const char *runtime_version, 57 | int argc, char* argv[], 58 | void **aot_modules, 59 | MonoBundledAssembly **bundled_assemblies, 60 | MonoBundledAssemblyConfig **configs, 61 | BundledAssemblyCleanup **cleanups); 62 | 63 | extern int mono_launcher_platform_exec (const char *main_assembly_name, int argc, char* argv[]); 64 | 65 | extern void mono_launcher_platform_terminate (); 66 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Xamarin.Windows.Build.Tasks")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Xamarin.Windows.Build.Tasks")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("36907f0d-086c-4144-a532-4e277ea0ceff")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion( 36 | ThisAssembly.Git.BaseVersion.Major + "." + 37 | ThisAssembly.Git.BaseVersion.Minor + "." + 38 | ThisAssembly.Git.BaseVersion.Patch + "." + 39 | ThisAssembly.Git.Commits)] 40 | [assembly: AssemblyInformationalVersion( 41 | ThisAssembly.Git.BaseVersion.Major + "." + 42 | ThisAssembly.Git.BaseVersion.Minor + "." + 43 | ThisAssembly.Git.BaseVersion.Patch + "." + 44 | ThisAssembly.Git.Commits + "-" + 45 | ThisAssembly.Git.Branch + "+" + 46 | ThisAssembly.Git.Commit)] 47 | 48 | [assembly: InternalsVisibleTo ("WindowsMSBuildTests")] 49 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Xamarin.Windows.Tasks.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xamarin.Windows.Tasks.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to #include "platform.h" 65 | /// 66 | ///// ${Defines} 67 | /// 68 | ///// ${AOTModules} 69 | ///// ${BundledAssemblies} 70 | ///// ${BundledAssemblyConfigs} 71 | ///// ${BundledAssemblyCleanups} 72 | /// 73 | ///#ifndef ROOT_DOMAIN_NAME 74 | ///#define ROOT_DOMAIN_NAME "Mono" 75 | ///#endif 76 | /// 77 | ///#ifndef RUNTIME_VERSION 78 | ///#define RUNTIME_VERSION NULL 79 | ///#endif 80 | /// 81 | ///int mono_launcher_initialize (int argc, char* argv[]) 82 | ///{ 83 | /// return mono_launcher_platform_initialize (ROOT_DOMAIN_NAME, RUNTIME_VERSION, 84 | /// argc, argv, 85 | /// GET_AOT_MODULES, GET_BUNDLED_ASSEMBLIES, 86 | /// GET_BUNDLED_ASSEMBLY_CONFIGS, GET_BUNDLED_ASSEMBLY_CLE [rest of string was truncated]";. 87 | /// 88 | internal static string LauncherTemplate { 89 | get { 90 | return ResourceManager.GetString("LauncherTemplate", resourceCulture); 91 | } 92 | } 93 | 94 | /// 95 | /// Looks up a localized string similar to int mono_main (int argc, char* argv[]); 96 | /// 97 | ///#include <stdlib.h> 98 | /// 99 | ///typedef struct { 100 | /// const char *name; 101 | /// const unsigned char *data; 102 | /// const unsigned int size; 103 | ///} MonoBundledAssembly; 104 | /// 105 | ///typedef struct { 106 | /// const char *name; 107 | /// const char *data; 108 | ///} MonoBundledAssemblyConfig; 109 | /// 110 | ///typedef MonoBundledAssembly *(BundledAssemblyGetter)(void); 111 | ///typedef MonoBundledAssemblyConfig *(BundledAssemblyConfigGetter)(void); 112 | ///typedef void (BundledAssemblyCleanup) (void); 113 | /// 114 | ///#define BEGIN_DECLARE_AOT_MODULES static void *_aot_modul [rest of string was truncated]";. 115 | /// 116 | internal static string PlatformHeader { 117 | get { 118 | return ResourceManager.GetString("PlatformHeader", resourceCulture); 119 | } 120 | } 121 | 122 | /// 123 | /// Looks up a localized string similar to #include <stdint.h> 124 | /// 125 | ///#include "platform.h" 126 | /// 127 | ///#define TRUE 1 128 | ///#define FALSE 0 129 | /// 130 | ///typedef int32_t gboolean; 131 | ///typedef struct _MonoAssembly MonoAssembly; 132 | ///typedef struct _MonoDomain MonoDomain; 133 | ///typedef enum { MONO_IMAGE_OK } MonoImageOpenStatus; 134 | /// 135 | ///extern void mono_jit_set_aot_only (gboolean val); 136 | ///extern void mono_aot_register_module (void *aot_info); 137 | ///extern void mono_register_bundled_assemblies (const MonoBundledAssembly **assemblies); 138 | ///extern void mono_register_config_for_assembly (const char* assembly_name, const cha [rest of string was truncated]";. 139 | /// 140 | internal static string PlatformImpl { 141 | get { 142 | return ResourceManager.GetString("PlatformImpl", resourceCulture); 143 | } 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\launchertemplate.c;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 123 | 124 | 125 | ..\platform.h;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 126 | 127 | 128 | ..\platform.c;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 129 | 130 | 131 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Tasks/ConvertDebuggingFiles.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading; 10 | using Microsoft.Build.Framework; 11 | using Microsoft.Build.Utilities; 12 | using Pdb2Mdb; 13 | 14 | namespace Xamarin.Windows.Tasks 15 | { 16 | public class ConvertDebuggingFiles : Task 17 | { 18 | // The .pdb files we need to convert 19 | [Required] 20 | public ITaskItem[] Files { get; set; } 21 | 22 | [Output] 23 | public ITaskItem[] MdbFiles { get; set; } 24 | 25 | [Output] 26 | public ITaskItem[] PPdbFiles { get; set; } 27 | 28 | public override bool Execute() 29 | { 30 | Log.LogDebugMessage("ConvertDebuggingFiles Task"); 31 | Log.LogDebugMessage(" Files: {0}", Files); 32 | 33 | var mdbs = new List(); 34 | var ppdbs = new List(); 35 | foreach (var file in Files) { 36 | var pdb = file.ToString(); 37 | 38 | if (!File.Exists(pdb)) { 39 | Log.LogDebugMessage(" Skipping non-existing file: {0}", pdb); 40 | continue; 41 | } 42 | 43 | try { 44 | var assembly = Path.ChangeExtension(pdb, ".dll"); 45 | if (!File.Exists(assembly)) 46 | assembly = Path.ChangeExtension(pdb, ".exe"); 47 | var mdb = assembly + ".mdb"; 48 | if (File.Exists(pdb) && File.Exists(mdb) && File.GetLastWriteTime(pdb) <= File.GetLastWriteTime(mdb)) { 49 | Log.LogDebugMessage(" Not converting unchanged file: {0}", pdb); 50 | } else { 51 | Log.LogDebugMessage(" Trying to convert file: {0} -> {1}", pdb, mdb); 52 | Converter.Convert(assembly); 53 | } 54 | mdbs.Add(mdb); 55 | } catch (PortablePdbNotSupportedException) { 56 | Log.LogDebugMessage("Not converting portable PDB: {0}", pdb); 57 | ppdbs.Add(pdb); 58 | } catch (Exception ex) { 59 | Log.LogWarningFromException(ex, true); 60 | } 61 | } 62 | 63 | MdbFiles = mdbs.Select(f => new TaskItem(f)).ToArray(); 64 | PPdbFiles = ppdbs.Select(f => new TaskItem(f)).ToArray(); 65 | Log.LogDebugTaskItems(" [Output] MdbFiles:", MdbFiles); 66 | Log.LogDebugTaskItems(" [Output] PPdbFiles:", PPdbFiles); 67 | 68 | return true; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Tasks/ExtractItems.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading; 10 | using Microsoft.Build.Framework; 11 | using Microsoft.Build.Utilities; 12 | using System.Xml; 13 | 14 | namespace Xamarin.Windows.Tasks 15 | { 16 | /// 17 | /// This MSBuild task extracts Items along with any custom metadata, 18 | /// from another project/msbuild file and outputs them in another msbuild 19 | /// file specified as an argument to the task. 20 | /// 21 | /// Example: 22 | /// This example will extract CLCompile items and AppxManifest items and 23 | /// put them in the (same) file specified by the variable ExtractItemsOutputFile. 24 | /// 25 | /// <ExtractItems Items="@(ClCompile)" ItemType="ClCompile" Output="$(ExtractItemsOutputFile)"/> 26 | /// <ExtractItems Items = "@(AppxManifest)" ItemType="AppxManifest" Output="$(ExtractItemsOutputFile)"/> 27 | /// 28 | /// 29 | /// If the file specified in ExtractItemsOutputFile already exist and is non-empty, 30 | /// this task will load the file and append the items. 31 | /// 32 | /// 33 | public class ExtractItems : Task, ICancelableTask 34 | { 35 | static readonly string MSBuildNamespace = "http://schemas.microsoft.com/developer/msbuild/2003"; 36 | 37 | [Required] 38 | public ITaskItem[] Items { get; set; } 39 | 40 | [Required] 41 | public string ItemType { get; set; } 42 | 43 | [Required] 44 | public string Output { get; set; } 45 | 46 | public string LinkMetadataName { get; set; } 47 | 48 | public bool IgnoreFullPaths { get; set; } 49 | 50 | public bool IgnoreLinks { get; set; } 51 | 52 | public override bool Execute() 53 | { 54 | try 55 | { 56 | if (!Directory.Exists(Path.GetDirectoryName(Output))) { 57 | Directory.CreateDirectory(Path.GetDirectoryName(Output)); 58 | } 59 | if (!File.Exists(Output) || new FileInfo(Output).Length == 0) 60 | { 61 | using (XmlWriter writer = XmlWriter.Create(Output)) 62 | { 63 | writer.WriteStartDocument(); 64 | writer.WriteStartElement("Project", MSBuildNamespace); 65 | writer.WriteEndElement(); 66 | writer.WriteEndDocument(); 67 | writer.Flush(); 68 | } 69 | } 70 | XmlDocument doc = new XmlDocument(); 71 | doc.Load(Output); 72 | XmlNode root = doc.DocumentElement; 73 | 74 | XmlElement group = doc.CreateElement("ItemGroup", MSBuildNamespace); 75 | root.AppendChild(group); 76 | 77 | if (string.IsNullOrEmpty(LinkMetadataName)) 78 | { 79 | LinkMetadataName = "Link"; 80 | } 81 | 82 | Log.LogDebugMessage("ExtractItems Task"); 83 | Log.LogDebugMessage(" ItemType: " + ItemType); 84 | Log.LogDebugMessage(" Output: " + Output); 85 | Log.LogDebugMessage(" LinkMetadataName: " + LinkMetadataName); 86 | Log.LogDebugMessage(" IgnoreFullPaths: " + IgnoreFullPaths); 87 | Log.LogDebugMessage(" IgnoreLinks: " + IgnoreLinks); 88 | Log.LogDebugMessage(" Items:"); 89 | 90 | foreach (ITaskItem item in Items) 91 | { 92 | IDictionary customMetadata = item.CloneCustomMetadata (); 93 | string includePath = ""; 94 | if (!IgnoreFullPaths && !customMetadata.Contains ("_IgnoreFullPath")) 95 | includePath = Path.GetFullPath (item.ItemSpec); 96 | else 97 | includePath = item.ItemSpec; 98 | 99 | Log.LogDebugMessage($" <{ItemType} Include=\"{includePath}\">"); 100 | XmlElement itemElement = doc.CreateElement(ItemType, MSBuildNamespace); 101 | XmlAttribute a = doc.CreateAttribute("Include"); 102 | a.Value = includePath; 103 | itemElement.Attributes.Append(a); 104 | 105 | var currDir = Canonicalize(Environment.CurrentDirectory); 106 | if (!IgnoreLinks && !customMetadata.Contains ("_IgnoreLink") && !Path.IsPathRooted(item.ItemSpec) 107 | && Canonicalize(Path.GetDirectoryName(Path.GetFullPath(item.ItemSpec))).ToLowerInvariant() != currDir.ToLowerInvariant() 108 | && !customMetadata.Contains(LinkMetadataName)) { 109 | 110 | var md = doc.CreateElement(LinkMetadataName, MSBuildNamespace); 111 | md.InnerText = item.ItemSpec; 112 | itemElement.AppendChild(md); 113 | Log.LogDebugMessage($" <{LinkMetadataName}>{item.ItemSpec}"); 114 | } 115 | foreach (string name in customMetadata.Keys) 116 | { 117 | var value = item.GetMetadata(name); 118 | Log.LogDebugMessage($" <{name}>{value}"); 119 | 120 | if (!name.StartsWith ("_", StringComparison.Ordinal)) 121 | { 122 | XmlElement md = doc.CreateElement (name, MSBuildNamespace); 123 | md.InnerText = value; 124 | itemElement.AppendChild (md); 125 | } 126 | } 127 | group.AppendChild(itemElement); 128 | Log.LogDebugMessage($" "); 129 | } 130 | 131 | doc.Save(Output); 132 | 133 | return true; 134 | } 135 | catch (Exception e) 136 | { 137 | Log.LogError("{0}", e); 138 | return false; 139 | } 140 | } 141 | 142 | static string Canonicalize(string path) 143 | { 144 | return new Uri(path).LocalPath; 145 | } 146 | 147 | public void Cancel() 148 | { 149 | throw new NotImplementedException(); 150 | } 151 | 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Tasks/GenerateBundledAssemblies.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Text.RegularExpressions; 9 | using Microsoft.Build.Framework; 10 | using Microsoft.Build.Utilities; 11 | 12 | namespace Xamarin.Windows.Tasks 13 | { 14 | public class GenerateBundledAssemblies : Task 15 | { 16 | 17 | [Required] 18 | public ITaskItem[] Assemblies { get; set; } 19 | 20 | [Required] 21 | public ITaskItem[] ConfigFiles { get; set; } 22 | 23 | [Required] 24 | public string OutputDirectory { get; set; } 25 | 26 | public bool SkipUnchanged { get; set; } 27 | 28 | [Output] 29 | public ITaskItem[] GeneratedFiles { get; set; } 30 | 31 | [Output] 32 | public ITaskItem[] BundledConfigFiles { get; set; } 33 | 34 | public override bool Execute() 35 | { 36 | try { 37 | return DoExecute(); 38 | } catch (Exception e) { 39 | Log.LogError("{0}", e); 40 | return false; 41 | } 42 | } 43 | 44 | private bool DoExecute() 45 | { 46 | Log.LogDebugMessage("GenerateBundledAssemblies Task"); 47 | Log.LogDebugTaskItems(" Assemblies:", Assemblies); 48 | Log.LogDebugTaskItems(" ConfigFiles:", ConfigFiles); 49 | Log.LogDebugMessage(" SkipUnchanged: {0}", SkipUnchanged); 50 | 51 | if (!Directory.Exists(OutputDirectory)) { 52 | Directory.CreateDirectory(OutputDirectory); 53 | } 54 | 55 | var outputFiles = new List(); 56 | var bundledConfigFiles = new List(); 57 | foreach (var assembly in Assemblies) { 58 | var outputFile = Path.Combine(OutputDirectory, Path.GetFileName(assembly.ItemSpec) + ".bundle.c"); 59 | string configFile; 60 | GenerateBundledAssembly(assembly.ItemSpec, outputFile, out configFile); 61 | outputFiles.Add(outputFile); 62 | if (configFile != null) { 63 | bundledConfigFiles.Add(configFile); 64 | } 65 | } 66 | GeneratedFiles = outputFiles.Select(f => new TaskItem(f)).ToArray(); 67 | BundledConfigFiles = bundledConfigFiles.Select(f => new TaskItem(f)).ToArray(); 68 | Log.LogDebugTaskItems(" [Output] GeneratedFiles:", GeneratedFiles); 69 | Log.LogDebugTaskItems(" [Output] BundledConfigFiles:", BundledConfigFiles); 70 | 71 | return true; 72 | } 73 | 74 | private static void WriteFileAsCArray(Stream ins, StreamWriter outs) 75 | { 76 | int n; 77 | var buffer = new byte[80 / 5]; 78 | while ((n = ins.Read(buffer, 0, buffer.Length)) != 0) { 79 | outs.Write("\t"); 80 | for (var i = 0; i < n; i++) { 81 | outs.Write("0x"); 82 | outs.Write(buffer[i].ToString("X2")); 83 | outs.Write(","); 84 | } 85 | outs.WriteLine(); 86 | } 87 | } 88 | 89 | public void GenerateBundledAssembly(string assemblyFile, string outputFile, out string configFile) 90 | { 91 | var assemblyName = Symbols.GetBundledAssemblyName(assemblyFile, Log); 92 | var assemblyConfigFileCopy = Path.Combine(Path.GetDirectoryName(outputFile), assemblyName) + ".config"; 93 | var configName = (assemblyName + ".config").ToLower(); 94 | try { 95 | configFile = ConfigFiles.First(t => Path.GetFileName(t.ItemSpec ?? "").ToLower() == configName).ItemSpec; 96 | } catch { 97 | configFile = null; 98 | } 99 | 100 | if (SkipUnchanged && File.Exists(outputFile) && File.Exists(assemblyFile) 101 | && File.GetLastWriteTime(outputFile) >= File.GetLastWriteTime(assemblyFile)) { 102 | if (configFile == null && !File.Exists(assemblyConfigFileCopy) 103 | || configFile != null && File.Exists(assemblyConfigFileCopy) && File.GetLastWriteTime(configFile) >= File.GetLastWriteTime(assemblyConfigFileCopy)) { 104 | Log.LogDebugMessage(" Not regenerating bundle file for unchanged assembly: {0}", assemblyFile); 105 | return; 106 | } 107 | } 108 | 109 | Log.LogDebugMessage($" Generating output '{outputFile}' from assembly '{assemblyFile}'"); 110 | var bundledAssemblyGetter = Symbols.GetBundledAssemblyGetter(assemblyName); 111 | var bundledAssemblyConfigGetter = Symbols.GetBundledAssemblyConfigGetter(assemblyName); 112 | var bundledAssemblyCleanup = Symbols.GetBundledAssemblyCleanup(assemblyName); 113 | using (var ins = File.OpenRead(assemblyFile)) { 114 | using (var outs = new StreamWriter(File.Create(outputFile))) { 115 | outs.WriteLine("static const unsigned char bundle_data [] = {"); 116 | WriteFileAsCArray(ins, outs); 117 | outs.WriteLine("};"); 118 | outs.WriteLine("typedef struct { const char* name; const unsigned char* data; const unsigned int size; } MonoBundledAssembly;"); 119 | outs.WriteLine($"static const MonoBundledAssembly bundle = {{\"{assemblyName}\", bundle_data, sizeof (bundle_data)}};"); 120 | outs.WriteLine($"const MonoBundledAssembly *{bundledAssemblyGetter} (void) {{ return &bundle; }}"); 121 | 122 | outs.WriteLine("typedef struct { const char* name; const char* data; } MonoBundledAssemblyConfig;"); 123 | if (configFile != null) { 124 | try { 125 | using (var cfgs = File.OpenRead(configFile)) { 126 | Log.LogDebugMessage($" Found assembly config file '{configFile}' for assembly '{assemblyFile}'"); 127 | outs.WriteLine("static const char config_data [] = {"); 128 | WriteFileAsCArray(cfgs, outs); 129 | outs.WriteLine("0};"); 130 | outs.WriteLine($"static const MonoBundledAssemblyConfig config = {{\"{assemblyName}\", config_data}};"); 131 | } 132 | } catch { 133 | // Return NULL if the assembly has no config file. 134 | configFile = null; 135 | } 136 | } 137 | if (configFile == null) { 138 | Log.LogDebugMessage($" No assembly config file found for assembly '{assemblyFile}'"); 139 | outs.WriteLine($"static const MonoBundledAssemblyConfig config = {{\"{assemblyName}\", 0L}};"); 140 | } 141 | if (File.Exists(assemblyConfigFileCopy)) { 142 | File.Delete(assemblyConfigFileCopy); 143 | } 144 | if (configFile != null) { 145 | File.Copy(configFile, assemblyConfigFileCopy); 146 | } 147 | outs.WriteLine($"const MonoBundledAssemblyConfig *{bundledAssemblyConfigGetter} (void) {{ return &config; }}"); 148 | 149 | // Cleanup function does nothing for now. Will be needed for compressed bundled. 150 | outs.WriteLine($"void {bundledAssemblyCleanup} (void) {{ return; }}"); 151 | } 152 | } 153 | } 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Utilities/MSBuildExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Diagnostics; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Text.RegularExpressions; 10 | 11 | using Microsoft.Build.Utilities; 12 | using Microsoft.Build.Framework; 13 | 14 | namespace Xamarin.Windows.Tasks 15 | { 16 | public static class MSBuildExtensions 17 | { 18 | private static bool IsRunningInsideVS { 19 | get { 20 | var vside = false; 21 | return bool.TryParse(Environment.GetEnvironmentVariable("VSIDE"), out vside) && vside; 22 | } 23 | } 24 | 25 | public static void LogDebugMessage(this TaskLoggingHelper log, string message, params object[] messageArgs) 26 | { 27 | log.LogMessage(MessageImportance.Low, message, messageArgs); 28 | } 29 | 30 | public static void LogTaskItems(this TaskLoggingHelper log, string message, ITaskItem[] items) 31 | { 32 | log.LogMessage(message); 33 | 34 | if (items == null) 35 | return; 36 | 37 | foreach (var item in items) 38 | log.LogMessage(" {0}", item.ItemSpec); 39 | } 40 | 41 | public static void LogTaskItems(this TaskLoggingHelper log, string message, params string[] items) 42 | { 43 | log.LogMessage(message); 44 | 45 | if (items == null) 46 | return; 47 | 48 | foreach (var item in items) 49 | log.LogMessage(" {0}", item); 50 | } 51 | 52 | public static void LogDebugTaskItems(this TaskLoggingHelper log, string message, ITaskItem[] items) 53 | { 54 | log.LogMessage(MessageImportance.Low, message); 55 | 56 | if (items == null) 57 | return; 58 | 59 | foreach (var item in items) 60 | log.LogMessage(MessageImportance.Low, " {0}", item.ItemSpec); 61 | } 62 | 63 | public static void LogDebugTaskItems(this TaskLoggingHelper log, string message, params string[] items) 64 | { 65 | log.LogMessage(MessageImportance.Low, message); 66 | 67 | if (items == null) 68 | return; 69 | 70 | foreach (var item in items) 71 | log.LogMessage(MessageImportance.Low, " {0}", item); 72 | } 73 | 74 | // looking for: mandroid: warning XA9000: message... 75 | static readonly Regex Message = new Regex( 76 | @"^(?[^: ]+)\s*:\s*(?warning|error) (?[^:]+): (?.*)"); 77 | 78 | public static void LogFromStandardError(this TaskLoggingHelper log, string message) 79 | { 80 | if (string.IsNullOrEmpty(message)) 81 | return; 82 | 83 | var m = Message.Match(message); 84 | if (!m.Success) 85 | return; 86 | 87 | string subcategory = m.Groups["source"].Value; 88 | string type = m.Groups["type"].Value; 89 | string code = m.Groups["code"].Value; 90 | string msg = m.Groups["message"].Value; 91 | 92 | if (type == "warning") 93 | log.LogWarning(subcategory, code, string.Empty, string.Empty, 0, 0, 0, 0, "{0}", msg); 94 | else 95 | log.LogError(subcategory, code, string.Empty, string.Empty, 0, 0, 0, 0, "{0}", msg); 96 | } 97 | 98 | public static void LogDebugTaskItemsAndLogical(this TaskLoggingHelper log, string message, ITaskItem[] items) 99 | { 100 | log.LogMessage(MessageImportance.Low, message); 101 | 102 | if (items == null) 103 | return; 104 | 105 | foreach (var item in items) { 106 | log.LogMessage(MessageImportance.Low, " {0}", item.ItemSpec); 107 | log.LogMessage(MessageImportance.Low, " [{0}]", item.GetMetadata("LogicalName")); 108 | } 109 | } 110 | 111 | public static void LogCodedError(this TaskLoggingHelper log, string code, string message, params object[] messageArgs) 112 | { 113 | log.LogError(string.Empty, code, string.Empty, string.Empty, 0, 0, 0, 0, message, messageArgs); 114 | } 115 | 116 | public static void LogCodedWarning(this TaskLoggingHelper log, string code, string message, params object[] messageArgs) 117 | { 118 | log.LogWarning( 119 | subcategory: string.Empty, 120 | warningCode: code, 121 | helpKeyword: string.Empty, 122 | file: string.Empty, 123 | lineNumber: 0, 124 | columnNumber: 0, 125 | endLineNumber: 0, 126 | endColumnNumber: 0, 127 | message: message, 128 | messageArgs: messageArgs); 129 | } 130 | 131 | public static IEnumerable Concat(params ITaskItem[][] values) 132 | { 133 | if (values == null) 134 | yield break; 135 | foreach (ITaskItem[] v in values) { 136 | if (v == null) 137 | continue; 138 | foreach (ITaskItem t in v) 139 | yield return t; 140 | } 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tasks/Utilities/Symbols.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.IO; 5 | using System.Text.RegularExpressions; 6 | using Microsoft.Build.Utilities; 7 | 8 | namespace Xamarin.Windows.Tasks 9 | { 10 | public class Symbols 11 | { 12 | 13 | public static string GetAotModuleSymbolName(string assemblyPath, string userSymbolPrefix = "") 14 | { 15 | var assemblyNameNoExt = Path.GetFileNameWithoutExtension(assemblyPath); 16 | return $"{userSymbolPrefix}mono_aot_module_{MangleAssemblyName(assemblyNameNoExt)}_info"; 17 | } 18 | 19 | public static string GetBundledAssemblyGetter(string assemblyName) 20 | { 21 | return $"mono_launcher_get_bundled_assembly_{MangleAssemblyName(assemblyName)}"; 22 | } 23 | 24 | public static string GetBundledAssemblyConfigGetter(string assemblyName) 25 | { 26 | return $"mono_launcher_get_bundled_assembly_config_{MangleAssemblyName(assemblyName)}"; 27 | } 28 | 29 | public static string GetBundledAssemblyCleanup(string assemblyName) 30 | { 31 | return $"mono_launcher_cleanup_bundled_assembly_{MangleAssemblyName(assemblyName)}"; 32 | } 33 | 34 | public static string GetBundledAssemblyName(string path, TaskLoggingHelper log) 35 | { 36 | string name = Path.GetFileName(path); 37 | 38 | // A bit of a hack to support satellite assemblies. They all share the same name but 39 | // are placed in subdirectories named after the locale they implement. Also, all of 40 | // them end in .resources.dll, therefore we can use that to detect the circumstances. 41 | if (name.EndsWith(".resources.dll", StringComparison.OrdinalIgnoreCase)) { 42 | string dir = Path.GetDirectoryName(path); 43 | int idx = dir.LastIndexOf(Path.DirectorySeparatorChar); 44 | if (idx >= 0) { 45 | name = dir.Substring(idx + 1) + Path.DirectorySeparatorChar + name; 46 | log.LogDebugMessage($"Storing satellite assembly '{path}' with name '{name}'"); 47 | } else { 48 | log.LogWarning($"Warning: satellite assembly {path} doesn't have locale path prefix, name conflicts possible"); 49 | } 50 | } 51 | 52 | return name; 53 | } 54 | 55 | private readonly static Regex AssemblyNameEscapeRe = new Regex("[^\\w_]"); 56 | public static string MangleAssemblyName(string assemblyName) 57 | { 58 | return AssemblyNameEscapeRe.Replace(assemblyName, "_"); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tests/ExtractItemsTestExpected1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | DefaultValue 10 | 11 | 12 | DefaultValue 13 | 14 | 15 | dir\c.foo 16 | DefaultValue 17 | 18 | 19 | dir\d.bar 20 | ExplicitValue 21 | 22 | 23 | 24 | 25 | 26 | foo\bar.txt 27 | 28 | 29 | 30 | 31 | 32 | assets\foobar.txt 33 | Empty 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tests/ExtractItemsTestExpected2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | DefaultValue 10 | 11 | 12 | DefaultValue 13 | 14 | 15 | dir\c.foo 16 | DefaultValue 17 | 18 | 19 | dir\d.bar 20 | ExplicitValue 21 | 22 | 23 | 24 | 25 | 26 | foo\bar.txt 27 | 28 | 29 | 30 | 31 | 32 | assets\foobar.txt 33 | NotEmpty 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Xamarin.Windows.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("nunit.tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tests/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Xamarin.Windows.Build.Tests.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xamarin.Windows.Build.Tests.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?> 65 | ///<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 66 | /// <ItemGroup> 67 | /// <Items1 Include="$(TestProjects)\ConsoleApp\a.foo" /> 68 | /// <Items1 Include="$(TestProjects)\ConsoleApp\b.foo" /> 69 | /// </ItemGroup> 70 | /// <ItemGroup> 71 | /// <Items2 Include="$(TestProjects)\ConsoleApp\a.foo"> 72 | /// <SomeMetadata>DefaultValue</SomeMetadata> 73 | /// </Items2> 74 | /// <Items2 Include="$(TestProjects)\ConsoleApp\b.foo"> 75 | /// <SomeMetadata>DefaultValue</SomeMetadata> 76 | /// </Items2> 77 | /// <Ite [rest of string was truncated]";. 78 | /// 79 | internal static string ExtractItemsTestExpected1 { 80 | get { 81 | return ResourceManager.GetString("ExtractItemsTestExpected1", resourceCulture); 82 | } 83 | } 84 | 85 | /// 86 | /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?> 87 | ///<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 88 | /// <ItemGroup> 89 | /// <Items1 Include="$(TestProjects)\ConsoleApp\a.foo" /> 90 | /// <Items1 Include="$(TestProjects)\ConsoleApp\b.foo" /> 91 | /// </ItemGroup> 92 | /// <ItemGroup> 93 | /// <Items2 Include="$(TestProjects)\ConsoleApp\a.foo"> 94 | /// <SomeMetadata>DefaultValue</SomeMetadata> 95 | /// </Items2> 96 | /// <Items2 Include="$(TestProjects)\ConsoleApp\b.foo"> 97 | /// <SomeMetadata>DefaultValue</SomeMetadata> 98 | /// </Items2> 99 | /// <Ite [rest of string was truncated]";. 100 | /// 101 | internal static string ExtractItemsTestExpected2 { 102 | get { 103 | return ResourceManager.GetString("ExtractItemsTestExpected2", resourceCulture); 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tests/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\ExtractItemsTestExpected1.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 123 | 124 | 125 | ..\ExtractItemsTestExpected2.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 126 | 127 | 128 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tests/TestBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Reflection; 8 | using Microsoft.Build.Evaluation; 9 | using Microsoft.Build.Execution; 10 | using Microsoft.Build.Framework; 11 | using Microsoft.Build.Logging; 12 | using NUnit.Framework; 13 | 14 | namespace Xamarin.Windows.Build.Tests 15 | { 16 | public abstract class TestBase 17 | { 18 | 19 | public static readonly string TestProjectsRoot; 20 | public static readonly string MonoDevRoot; 21 | public static readonly string MonoDevBcl; 22 | public static readonly string ReferenceAssemblies; 23 | 24 | static TestBase() 25 | { 26 | var currentDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); 27 | var rootDir = Canonicalize(Path.Combine(currentDir, @"..\..\..\..")); 28 | var props = new Project(Path.Combine(rootDir, "Xamarin.Windows.props")).AllEvaluatedProperties; 29 | 30 | TestProjectsRoot = Canonicalize(Path.Combine(rootDir, @"msbuild\TestProjects")); 31 | MonoDevRoot = props.Where(p => p.Name == "MonoDevRoot").Select(p => p.EvaluatedValue).First(); 32 | MonoDevBcl = Canonicalize(Path.Combine(MonoDevRoot, @"mcs\class\lib\winaot")); 33 | ReferenceAssemblies = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.Windows\v1.0"; 34 | } 35 | 36 | static string Canonicalize(string path) 37 | { 38 | return new Uri(path).LocalPath; 39 | } 40 | 41 | protected static string ReplaceRoots(string path) 42 | { 43 | if (path.StartsWith(TestProjectsRoot, StringComparison.CurrentCultureIgnoreCase)) { 44 | return "$(TestProjectsRoot)\\" + path.Substring(TestProjectsRoot.Length + 1); 45 | } 46 | if (path.StartsWith(MonoDevBcl, StringComparison.CurrentCultureIgnoreCase)) { 47 | return "$(MonoDevBcl)\\" + path.Substring(MonoDevBcl.Length + 1); 48 | } 49 | if (path.StartsWith(MonoDevRoot, StringComparison.CurrentCultureIgnoreCase)) { 50 | return "$(MonoDevRoot)\\" + path.Substring(MonoDevRoot.Length + 1); 51 | } 52 | if (path.StartsWith(ReferenceAssemblies, StringComparison.CurrentCultureIgnoreCase)) { 53 | return "$(ReferenceAssemblies)\\" + path.Substring(ReferenceAssemblies.Length + 1); 54 | } 55 | return path; 56 | } 57 | 58 | protected static string[] GetPathItems(BuildResult result, string itemType) 59 | { 60 | return result.ProjectStateAfterBuild.Items 61 | .Where(i => i.ItemType == itemType) 62 | .Select(i => ReplaceRoots(i.EvaluatedInclude)) 63 | .OrderBy(s => s) 64 | .ToArray(); 65 | } 66 | 67 | protected static string GetTestProjectDir(string name) 68 | { 69 | return Path.Combine(TestProjectsRoot, name); 70 | } 71 | 72 | public BuildResult BuildProject(string projectName, string targets = "Build", object properties = null) 73 | { 74 | var props = properties?.GetType().GetProperties().ToDictionary(p => p.Name, p => p.GetValue(properties).ToString()) ?? new Dictionary(); 75 | var projectPath = Path.Combine(GetTestProjectDir(projectName), projectName + ".csproj"); 76 | var loggers = new List {new ConsoleLogger(LoggerVerbosity.Detailed)}; 77 | var buildParameters = new BuildParameters(new ProjectCollection()) { Loggers = loggers }; 78 | var buildRequest = new BuildRequestData(projectPath, props, null, 79 | targets.Split(';'), null, BuildRequestDataFlags.ProvideProjectStateAfterBuild); 80 | var buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest); 81 | Assert.AreEqual(BuildResultCode.Success, buildResult.OverallResult, 82 | "Failed to build target(s) {0} in project {1}", targets, projectName); 83 | return buildResult; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.Build.Tests/Xamarin.Windows.Build.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8EDF4429-251A-416D-BB68-93F227191BCF} 8 | Library 9 | Properties 10 | Xamarin.Windows.Build.Tests 11 | Xamarin.Windows.Build.Tests 12 | v4.6 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | bin\Test\ 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | True 51 | True 52 | Resources.resx 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | ResXFileCodeGenerator 68 | Resources.Designer.cs 69 | 70 | 71 | 72 | 79 | -------------------------------------------------------------------------------- /msbuild/Xamarin.Windows.CSharp.targets: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 25 | 27 | 28 | 29 | 30 | Xamarin.Windows 31 | v1.0 32 | 33 | 35 | $(VsInstallRoot)\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\ 36 | $(ProgramFiles)\Reference Assemblies\Microsoft\Framework\ 37 | 38 | 39 | 40 | 41 | 42 | 49 | 51 | 52 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/Guids.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace Xamarin.Windows.Properties 6 | { 7 | static class Guids 8 | { 9 | // NOTE: changing the package GUID depending on the solution being built is 10 | // the only reliable way (in addition to changing the extension assembly 11 | // name itself) to guarantee that VS will be able to load them side-by-side. 12 | public const string PackageGuidString = "0610d5ad-36f3-4a90-a0ba-55736bf813c1"; 13 | public const string guidPackageString = PackageGuidString; 14 | // public const string guidCommandSetString = ThisAssembly.Vsix.CommandSetGuid; 15 | public const string WindowsBindingProjectTypeGuid = "8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED"; 16 | 17 | public const string OptionsPageGuidString = "9889e6f4-595b-4f13-8913-2c3acb3263e0"; 18 | public static readonly Guid guidPackage = new Guid(guidPackageString); 19 | 20 | }; 21 | } -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/vs/Xamarin.Windows.Properties/Key.snk -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/OptionsPage.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | using Xamarin.Windows.Properties.Properties; 7 | 8 | namespace Xamarin.Windows.Properties 9 | { 10 | [Guid(Guids.OptionsPageGuidString)] 11 | public class OptionsPage : BasePropertyPage 12 | { 13 | protected OptionsPageViewModel model; 14 | 15 | protected override string Title => Resources.OptionsTitle; 16 | 17 | protected override FrameworkElement CreateView() => new OptionsPageView(); 18 | 19 | protected override ViewModelBase CreateViewModel() { return model = new OptionsPageViewModel// Copyright(c) Microsoft Corporation.All rights reserved. 20 | // Licensed under the MIT License. 21 | (); } 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/OptionsPageView.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 36 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/OptionsPageView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Xamarin.Windows.Properties 17 | { 18 | /// 19 | /// Interaction logic for OptionsPageView.xaml 20 | /// 21 | public partial class OptionsPageView : UserControl 22 | { 23 | public OptionsPageView() { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/OptionsPageViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Xamarin.Windows.Properties 5 | { 6 | public class OptionsPageViewModel : ViewModelBase 7 | { 8 | public string AdditionalAotArguments { 9 | get { return GetPropertyValue(); } 10 | set { SetPropertyValue(value); } 11 | } 12 | 13 | public string AdditionalMonoOptions { 14 | get { return GetPropertyValue(); } 15 | set { SetPropertyValue(value); } 16 | } 17 | public string MonoLogLevel { 18 | get { return GetPropertyValue(); } 19 | set { SetPropertyValue(value); } 20 | } 21 | public string MonoLogMask { 22 | get { return GetPropertyValue(); } 23 | set { SetPropertyValue(value); } 24 | } 25 | 26 | public bool GenerateDebuggableAotModules { 27 | get { return GetPropertyValue(); } 28 | set { SetPropertyValue(value); } 29 | } 30 | 31 | public bool BundleAssemblies { 32 | get { return GetPropertyValue(); } 33 | set { SetPropertyValue(value); } 34 | } 35 | 36 | public bool EnableAotMode { 37 | get { return GetPropertyValue(); } 38 | set { SetPropertyValue(value); } 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("Xamarin.Windows.Properties")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("Xamarin.Windows.Properties")] 15 | [assembly: AssemblyCopyright("")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Xamarin.Windows.Properties.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | public class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | public static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xamarin.Windows.Properties.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | public static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Additional AOT Options. 65 | /// 66 | public static string AdditionalAotOptions { 67 | get { 68 | return ResourceManager.GetString("AdditionalAotOptions", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to Mono Command Line Options. 74 | /// 75 | public static string AdditionalMonoOptions { 76 | get { 77 | return ResourceManager.GetString("AdditionalMonoOptions", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to Arguments --debug --debugger-agent=transport=dt_socket,address=127.0.0.1:<port> will be added automatically.. 83 | /// 84 | public static string AdditionalMonoOptionsHelpText { 85 | get { 86 | return ResourceManager.GetString("AdditionalMonoOptionsHelpText", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// Looks up a localized string similar to AOT Compilation. 92 | /// 93 | public static string AotMode { 94 | get { 95 | return ResourceManager.GetString("AotMode", resourceCulture); 96 | } 97 | } 98 | 99 | /// 100 | /// Looks up a localized string similar to AOT Compilation Enabled. 101 | /// 102 | public static string AotModePropertyName { 103 | get { 104 | return ResourceManager.GetString("AotModePropertyName", resourceCulture); 105 | } 106 | } 107 | 108 | /// 109 | /// Looks up a localized string similar to Bundle Assemblies. 110 | /// 111 | public static string BundleAssemblies { 112 | get { 113 | return ResourceManager.GetString("BundleAssemblies", resourceCulture); 114 | } 115 | } 116 | 117 | /// 118 | /// Looks up a localized string similar to Debuggable Assemblies. 119 | /// 120 | public static string GenerateDebuggableAotModules { 121 | get { 122 | return ResourceManager.GetString("GenerateDebuggableAotModules", resourceCulture); 123 | } 124 | } 125 | 126 | /// 127 | /// Looks up a localized string similar to JIT Compilation. 128 | /// 129 | public static string JitMode { 130 | get { 131 | return ResourceManager.GetString("JitMode", resourceCulture); 132 | } 133 | } 134 | 135 | /// 136 | /// Looks up a localized string similar to JIT Compilation Enabled. 137 | /// 138 | public static string JitModePropertyName { 139 | get { 140 | return ResourceManager.GetString("JitModePropertyName", resourceCulture); 141 | } 142 | } 143 | 144 | /// 145 | /// Looks up a localized string similar to More info about. 146 | /// 147 | public static string MonoLoggingHelpText { 148 | get { 149 | return ResourceManager.GetString("MonoLoggingHelpText", resourceCulture); 150 | } 151 | } 152 | 153 | /// 154 | /// Looks up a localized string similar to Logging Mono Runtime Events. 155 | /// 156 | public static string MonoLoggingLinkHelpText { 157 | get { 158 | return ResourceManager.GetString("MonoLoggingLinkHelpText", resourceCulture); 159 | } 160 | } 161 | 162 | /// 163 | /// Looks up a localized string similar to Mono trace level (MONO_LOG_LEVEL). 164 | /// 165 | public static string MonoLogLevel { 166 | get { 167 | return ResourceManager.GetString("MonoLogLevel", resourceCulture); 168 | } 169 | } 170 | 171 | /// 172 | /// Looks up a localized string similar to Mono trace filters (MONO_LOG_MASK). 173 | /// 174 | public static string MonoLogMask { 175 | get { 176 | return ResourceManager.GetString("MonoLogMask", resourceCulture); 177 | } 178 | } 179 | 180 | /// 181 | /// Looks up a localized string similar to Xamarin. 182 | /// 183 | public static string OptionsTitle { 184 | get { 185 | return ResourceManager.GetString("OptionsTitle", resourceCulture); 186 | } 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Additional AOT Options 122 | 123 | 124 | Mono Command Line Options 125 | 126 | 127 | Arguments --debug --debugger-agent=transport=dt_socket,address=127.0.0.1:<port> will be added automatically. 128 | 129 | 130 | AOT Compilation 131 | 132 | 133 | AOT Compilation Enabled 134 | 135 | 136 | Bundle Assemblies 137 | 138 | 139 | Debuggable Assemblies 140 | 141 | 142 | JIT Compilation 143 | 144 | 145 | JIT Compilation Enabled 146 | 147 | 148 | More info about 149 | 150 | 151 | Logging Mono Runtime Events 152 | 153 | 154 | Mono trace level (MONO_LOG_LEVEL) 155 | 156 | 157 | Mono trace filters (MONO_LOG_MASK) 158 | 159 | 160 | Xamarin 161 | 162 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VisualStudio.Properties/BuildPropertyStorage.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using Clide; 4 | using Microsoft.Build.Construction; 5 | using Microsoft.Build.Evaluation; 6 | using Microsoft.VisualStudio.Shell.Interop; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.ComponentModel; 10 | using System.Linq; 11 | 12 | namespace Xamarin.Windows.Properties 13 | { 14 | public class BuildPropertyStorage : IPropertyStorage 15 | { 16 | const string PlatformPropertyName = "Platform"; 17 | const string ConfigurationPropertyName = "Configuration"; 18 | 19 | readonly Dictionary pendingValuesToBePersisted = new Dictionary(); 20 | readonly Dictionary pendingUserValuesToBePersisted = new Dictionary(); 21 | readonly bool commitChangesImmediately; 22 | readonly string configName = null; 23 | readonly JoinableLazy project; 24 | readonly JoinableLazy projectNode; 25 | 26 | string configurationName; 27 | string platformName; 28 | 29 | public BuildPropertyStorage(IVsHierarchy hierarchy, string configName = null, bool commitChangesImmediately = true) 30 | { 31 | this.configName = configName; 32 | this.commitChangesImmediately = commitChangesImmediately; 33 | 34 | project = new JoinableLazy(() => 35 | { 36 | var dteProject = hierarchy.AsDteProject(); 37 | 38 | if (dteProject != null) 39 | return ProjectCollection.GlobalProjectCollection.GetLoadedProjects(dteProject.FullName).FirstOrDefault(); 40 | 41 | return null; 42 | }, executeOnMainThread: true); 43 | 44 | projectNode = new JoinableLazy(() => 45 | { 46 | var dteProject = hierarchy.AsDteProject(); 47 | 48 | if (dteProject != null) 49 | return dteProject.AsProjectNode(); 50 | 51 | return null; 52 | }, executeOnMainThread: true); 53 | 54 | if (!string.IsNullOrEmpty(configName)) 55 | { 56 | var values = configName.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); 57 | if (values.Any()) 58 | configurationName = values[0].Trim(); 59 | if (values.Length > 1) 60 | platformName = values[1].Trim(); 61 | } 62 | } 63 | 64 | Project Project => project.GetValue(); 65 | 66 | IProjectNode ProjectNode => projectNode.GetValue(); 67 | 68 | public string Condition { get; set; } 69 | 70 | public T GetPropertyValue(string propertyName) 71 | { 72 | return GetPropertyValue(propertyName, default(T)); 73 | } 74 | 75 | public T GetPropertyValue(string propertyName, T defaultValue) 76 | { 77 | object value = null; 78 | 79 | string valueAsString; 80 | 81 | // Configuration and Platform are special cases because they can be changed/switched 82 | // by the Configuration/Platform selector in the property page and these changes are not 83 | // propagated to the .csproj 84 | if (propertyName == ConfigurationPropertyName && !string.IsNullOrEmpty(configurationName)) 85 | { 86 | valueAsString = configurationName; 87 | } 88 | else if (propertyName == PlatformPropertyName && !string.IsNullOrEmpty(platformName)) 89 | { 90 | valueAsString = platformName; 91 | } 92 | else if (!pendingValuesToBePersisted.TryGetValue(propertyName, out valueAsString)) 93 | { 94 | var group = GetSelectedPropertyGroup(); 95 | 96 | if (group != null) 97 | { 98 | var property = group.Properties.FirstOrDefault(x => x.Name == propertyName); 99 | if (property == null) 100 | // Search in the global section 101 | property = Project.Xml.PropertyGroups.FirstOrDefault()?.Properties.FirstOrDefault(x => x.Name == propertyName); 102 | 103 | if (property != null) 104 | valueAsString = property.Value; 105 | } 106 | } 107 | 108 | if (valueAsString != null) 109 | { 110 | if (typeof(T) != typeof(string)) 111 | value = TypeDescriptor 112 | .GetConverter(typeof(T)) 113 | .ConvertFromString(valueAsString); 114 | else 115 | value = valueAsString; 116 | } 117 | 118 | return value != null ? (T)value : defaultValue; 119 | } 120 | 121 | public void SetPropertyValue(T propertyValue, string propertyName) 122 | { 123 | var value = string.Empty; 124 | if (propertyValue != null) 125 | { 126 | if (propertyValue is String) 127 | { 128 | value = propertyValue.ToString(); 129 | } 130 | else 131 | { 132 | value = TypeDescriptor 133 | .GetConverter(propertyValue.GetType()) 134 | .ConvertToString(propertyValue); 135 | 136 | if (propertyValue is Boolean) 137 | value = value.ToLowerInvariant(); 138 | } 139 | } 140 | 141 | pendingValuesToBePersisted[propertyName] = value; 142 | 143 | if (commitChangesImmediately) 144 | CommitChanges(); 145 | } 146 | 147 | public void SetUserPropertyValue(T propertyValue, string propertyName) 148 | { 149 | var value = string.Empty; 150 | if (propertyValue != null) 151 | { 152 | if (propertyValue is String) 153 | { 154 | value = propertyValue.ToString(); 155 | } 156 | else 157 | { 158 | value = TypeDescriptor 159 | .GetConverter(propertyValue.GetType()) 160 | .ConvertToString(propertyValue); 161 | 162 | if (propertyValue is Boolean) 163 | value = value.ToLowerInvariant(); 164 | } 165 | } 166 | 167 | pendingUserValuesToBePersisted[propertyName] = value; 168 | 169 | if (commitChangesImmediately) 170 | CommitChanges(); 171 | } 172 | 173 | public void CommitChanges() 174 | { 175 | foreach (var kvp in pendingValuesToBePersisted) 176 | CommitChange(kvp.Key, kvp.Value); 177 | 178 | foreach (var kvp in pendingUserValuesToBePersisted) 179 | CommitUserPropertyChange(kvp.Key, kvp.Value); 180 | 181 | pendingValuesToBePersisted.Clear(); 182 | pendingUserValuesToBePersisted.Clear(); 183 | } 184 | 185 | void CommitChange(string propertyName, string value) 186 | { 187 | if (Project != null) 188 | { 189 | var group = GetSelectedPropertyGroup(); 190 | if (group == null && !string.IsNullOrEmpty(Condition)) 191 | { 192 | group = Project.Xml.AddPropertyGroup(); 193 | group.Condition = Condition; 194 | } 195 | 196 | if (group != null) 197 | group.SetProperty(propertyName, value); 198 | } 199 | } 200 | 201 | void CommitUserPropertyChange(string propertyName, string value) 202 | { 203 | if (ProjectNode != null) 204 | ProjectNode.UserProperties[propertyName] = value; 205 | } 206 | 207 | ProjectPropertyGroupElement GetSelectedPropertyGroup() 208 | { 209 | ProjectPropertyGroupElement group; 210 | if (!string.IsNullOrEmpty(Condition)) 211 | { 212 | group = Project 213 | .Xml 214 | .PropertyGroups 215 | .Where(x => !string.IsNullOrEmpty(x.Condition)) 216 | .FirstOrDefault(x => 217 | string.Equals( 218 | x.Condition.Replace(" ", string.Empty), 219 | Condition.Replace(" ", string.Empty), 220 | StringComparison.OrdinalIgnoreCase)); 221 | } 222 | else if (!string.IsNullOrEmpty(configName)) 223 | { 224 | var validGroups = Project.Xml.PropertyGroups.Where(x => !string.IsNullOrEmpty(x.Condition)); 225 | 226 | group = validGroups.FirstOrDefault(x => x.Condition.TrimEnd(new char[] { '\'', '"', ' ' }).EndsWith(configName)); 227 | 228 | if (group == null) 229 | // If it is still null, try using the configName without spaces 230 | // For example "Any CPU" could be "AnyCPU" 231 | group = validGroups.FirstOrDefault(x => x.Condition.TrimEnd(new char[] { '\'', '"', ' ' }).EndsWith(configName.Replace("Any CPU", "AnyCPU"))); 232 | } 233 | else 234 | { 235 | group = Project.Xml.PropertyGroups.FirstOrDefault(); 236 | } 237 | 238 | return group; 239 | } 240 | 241 | public T GetUserPropertyValue(string propertyName) 242 | { 243 | object value = null; 244 | 245 | if (!pendingUserValuesToBePersisted.TryGetValue(propertyName, out string valueAsString)) 246 | { 247 | value = ProjectNode.UserProperties[propertyName]; 248 | } 249 | 250 | if (valueAsString != null) 251 | { 252 | if (typeof(T) != typeof(string)) 253 | value = TypeDescriptor 254 | .GetConverter(typeof(T)) 255 | .ConvertFromString(valueAsString); 256 | else 257 | value = valueAsString; 258 | } 259 | 260 | return (T)value; 261 | } 262 | } 263 | } -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VisualStudio.Properties/Constants.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Xamarin.Windows.Properties 10 | { 11 | internal class Constants 12 | { 13 | public const uint SW_SHOW = 5; 14 | public const uint SW_SHOWNORMAL = 1; 15 | public const uint SW_HIDE = 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VisualStudio.Properties/Extensions/IVsHierarchyExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using EnvDTE; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace Microsoft.VisualStudio.Shell.Interop 9 | { 10 | public static class IVsHierarchyExtensions 11 | { 12 | public static Project AsDteProject(this IVsHierarchy hierarchy) 13 | { 14 | if (hierarchy != null) 15 | { 16 | object project; 17 | if (ErrorHandler.Succeeded( 18 | hierarchy.GetProperty( 19 | VSConstants.VSITEMID_ROOT, 20 | (int)__VSHPROPID.VSHPROPID_ExtObject, 21 | out project))) 22 | return project as Project; 23 | } 24 | 25 | return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VisualStudio.Properties/IItemsProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Xamarin.Windows.Properties 10 | { 11 | public interface IItemsProvider 12 | { 13 | IEnumerable GetItems(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VisualStudio.Properties/IPropertyStorage.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Runtime.CompilerServices; 9 | 10 | namespace Xamarin.Windows.Properties 11 | { 12 | public interface IPropertyStorage 13 | { 14 | T GetPropertyValue(string propertyName); 15 | T GetPropertyValue(string propertyName, T defaultValue); 16 | T GetUserPropertyValue(string propertyName); 17 | void SetPropertyValue(T value, string propertyName); 18 | void SetUserPropertyValue(T propertyValue, string propertyName); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VisualStudio.Properties/InMemoryPropertyStorage.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.CompilerServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace Xamarin.Windows.Properties 11 | { 12 | public class InMemoryPropertyStorage : IPropertyStorage 13 | { 14 | Dictionary values = new Dictionary(); 15 | 16 | public T GetPropertyValue(string propertyName) 17 | { 18 | object value; 19 | if (values.TryGetValue(propertyName, out value)) 20 | return (T)value; 21 | 22 | return default(T); 23 | } 24 | 25 | public T GetPropertyValue(string propertyName, T defaultValue) 26 | { 27 | object value; 28 | if (values.TryGetValue(propertyName, out value)) 29 | return (T)value; 30 | 31 | return defaultValue; 32 | } 33 | 34 | public void SetPropertyValue(T value, string propertyName) => 35 | values[propertyName] = value; 36 | 37 | public T GetUserPropertyValue(string propertyName) => throw new NotImplementedException(); 38 | 39 | public void SetUserPropertyValue(T propertyValue, string propertyName) => throw new NotImplementedException(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VisualStudio.Properties/ItemViewModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Xamarin.Windows.Properties 10 | { 11 | public class ItemViewModel 12 | { 13 | public ItemViewModel() 14 | { } 15 | 16 | public ItemViewModel(string displayName, string value, string group = "") 17 | { 18 | DisplayName = displayName; 19 | Value = value; 20 | Group = group; 21 | } 22 | 23 | public string DisplayName { get; set; } 24 | public string Value { get; set; } 25 | public string Group { get; set; } 26 | public bool IsDefault { get; set; } 27 | public object Data { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VisualStudio.Properties/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Collections.ObjectModel; 7 | using System.ComponentModel; 8 | using System.ComponentModel.DataAnnotations; 9 | using System.Linq; 10 | using System.Linq.Expressions; 11 | using System.Reactive.Disposables; 12 | using System.Reflection; 13 | using System.Runtime.CompilerServices; 14 | using System.Text; 15 | 16 | namespace Xamarin.Windows.Properties 17 | { 18 | public abstract class ViewModelBase : INotifyPropertyChanged, IDataErrorInfo, IDisposable 19 | { 20 | bool disposed; 21 | 22 | public event PropertyChangedEventHandler PropertyChanged; 23 | public event EventHandler ValidationFailed; 24 | 25 | readonly Dictionary> errorSummaryByColumnName = new Dictionary>(); 26 | readonly CompositeDisposable disposables = new CompositeDisposable(); 27 | 28 | IPropertyStorage storage; 29 | 30 | // Support for design data context 31 | public ViewModelBase() 32 | : this(new InMemoryPropertyStorage()) 33 | { } 34 | 35 | public ViewModelBase(IPropertyStorage storage) 36 | { 37 | // DO NOT USE the property at this stage 38 | // We want to avoid triggering the OnStorageChange/InvalidaProperties handlers 39 | // when the instance is being created 40 | this.storage = storage; 41 | } 42 | 43 | public IPropertyStorage Storage 44 | { 45 | get { return storage; } 46 | set 47 | { 48 | storage = value; 49 | 50 | OnStorageChanged(); 51 | InvalidateProperties(); 52 | } 53 | } 54 | 55 | protected virtual void OnStorageChanged() 56 | { 57 | } 58 | 59 | public bool IsRefreshing { get; set; } 60 | 61 | public virtual string Error 62 | { 63 | get 64 | { 65 | var result = new StringBuilder(); 66 | foreach (var validationResult in errorSummaryByColumnName.SelectMany(x => x.Value)) 67 | if (!string.IsNullOrEmpty(validationResult.ErrorMessage)) 68 | result.AppendLine(validationResult.ErrorMessage); 69 | 70 | return result.Length == 0 ? null : result.ToString(); 71 | } 72 | } 73 | 74 | public virtual bool IsValid => 75 | !errorSummaryByColumnName.Any(x => x.Value.Any()); 76 | 77 | public virtual string this[string columnName] 78 | { 79 | get 80 | { 81 | string result = null; 82 | 83 | var propertyInfo = GetType().GetTypeInfo().GetProperty(columnName); 84 | if (propertyInfo != null) 85 | ValidateProperty(columnName, propertyInfo.GetValue(this), out result); 86 | 87 | return result; 88 | } 89 | } 90 | 91 | bool ValidateProperty(string memberName, object value, out string result) 92 | { 93 | result = null; 94 | 95 | var validationContext = new ValidationContext(this) 96 | { 97 | MemberName = memberName 98 | }; 99 | 100 | var validationResults = new List(); 101 | if (!Validator.TryValidateProperty(value, validationContext, validationResults)) 102 | result = string.Join(Environment.NewLine, validationResults.Select(x => x.ErrorMessage)); 103 | 104 | errorSummaryByColumnName[memberName] = validationResults; 105 | 106 | return !validationResults.Any(); 107 | } 108 | 109 | protected void SetUserPropertyValue(T value, [CallerMemberName] string memberName = "") => 110 | SetUserPropertyValue(value, false, memberName); 111 | 112 | protected void SetUserPropertyValue(T value, bool ignoreValidationResult, string memberName) 113 | { 114 | SetPropertyValue(value, ignoreValidationResult, memberName, () => Storage.SetUserPropertyValue(value, memberName)); 115 | } 116 | 117 | protected void SetPropertyValue(T value, [CallerMemberName] string memberName = "") => 118 | SetPropertyValue(value, false, memberName); 119 | 120 | protected void SetPropertyValue(T value, bool ignoreValidationResult, string memberName) 121 | { 122 | SetPropertyValue(value, ignoreValidationResult, memberName, () => Storage.SetPropertyValue(value, memberName)); 123 | } 124 | 125 | void SetPropertyValue(T value, bool ignoreValidationResult, string memberName, Action setPropertyAction) 126 | { 127 | string result = null; 128 | if (ValidateProperty(memberName, value, out result) || ignoreValidationResult) 129 | { 130 | setPropertyAction(); 131 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName)); 132 | } 133 | else 134 | { 135 | InvalidateProperties(); 136 | ValidationFailed?.Invoke(this, result); 137 | } 138 | } 139 | 140 | protected void ResetPropertyValue([CallerMemberName] string memberName = "") 141 | { 142 | Storage.SetPropertyValue(string.Empty, memberName); 143 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName)); 144 | } 145 | 146 | protected T GetPropertyValue([CallerMemberName] string memberName = "") => 147 | Storage.GetPropertyValue(memberName); 148 | 149 | protected T GetPropertyValueOrDefault(T defaultValue, [CallerMemberName] string memberName = "") 150 | => Storage.GetPropertyValue(memberName, defaultValue); 151 | 152 | protected T GetUserPropertyValue([CallerMemberName] string memberName = "") => 153 | Storage.GetUserPropertyValue(memberName); 154 | 155 | public virtual void InvalidateProperties() 156 | { 157 | try 158 | { 159 | IsRefreshing = true; 160 | 161 | foreach (var provider in itemsProviders) 162 | { 163 | provider.Value.Clear(); 164 | 165 | foreach (var value in provider.Key.GetItems()) 166 | provider.Value.Add(value); 167 | 168 | } 169 | 170 | var targetProperties = GetType() 171 | .GetTypeInfo() 172 | .DeclaredProperties 173 | .Where(x => x.CanRead && x.CanWrite); 174 | 175 | foreach (var property in targetProperties) 176 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property.Name)); 177 | } 178 | finally 179 | { 180 | IsRefreshing = false; 181 | } 182 | } 183 | 184 | readonly Dictionary> itemsProviders = 185 | new Dictionary>(); 186 | 187 | protected void RegisterItemsProvider(IItemsProvider provider, ObservableCollection source) 188 | { 189 | itemsProviders.Add(provider, source); 190 | } 191 | 192 | protected virtual void NotifyPropertyChanged(Expression> expr, bool setRefresingIfNecessary = false) 193 | { 194 | // If IsRefreshing is already true we don't have to reset it at the end of this execution 195 | var resetRefresing = !IsRefreshing && setRefresingIfNecessary; 196 | 197 | try 198 | { 199 | if (resetRefresing) 200 | IsRefreshing = true; 201 | 202 | var memberExpression = expr.Body as MemberExpression; 203 | if (memberExpression != null) 204 | { 205 | var property = memberExpression.Member as PropertyInfo; 206 | if (property != null) 207 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property.Name)); 208 | } 209 | } 210 | finally 211 | { 212 | if (resetRefresing) 213 | IsRefreshing = false; 214 | } 215 | } 216 | 217 | protected void NotifyPropertyChanged(params string[] propertyNames) 218 | { 219 | foreach (var propertyName in propertyNames) 220 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 221 | } 222 | 223 | public void Dispose() 224 | { 225 | Dispose(true); 226 | 227 | GC.SuppressFinalize(this); 228 | } 229 | 230 | protected virtual void Dispose(bool disposing) 231 | { 232 | if (disposed) 233 | return; 234 | 235 | if (disposing) 236 | disposables.Dispose(); 237 | 238 | disposed = true; 239 | } 240 | 241 | protected virtual void TrackDisposable(IDisposable value) => 242 | disposables.Add(value); 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/VsPackage.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) Microsoft Corporation.All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using Microsoft.VisualStudio.Shell; 6 | 7 | namespace Xamarin.Windows.Properties 8 | { 9 | [Guid(Guids.guidPackageString)] 10 | [PackageRegistration(UseManagedResourcesOnly = true)] 11 | [ProvideMenuResource("2000", 13)] 12 | [ProvideObject(typeof(OptionsPage), RegisterUsing = RegistrationMethod.CodeBase)] 13 | public sealed class VsPackage : AsyncPackage 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.Properties/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Xamarin.Windows.Properties 6 | Configuration properties for Xamarin Windows. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/ConsoleApplication/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("$projectname$")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("$registeredorganization$")] 12 | [assembly: AssemblyProduct("$projectname$")] 13 | [assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("$guid1$")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/ConsoleApplication/CSharpConsoleApplication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | $guid1$ 9 | {8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | Exe 11 | Properties 12 | $safeprojectname$ 13 | $safeprojectname$ 14 | v1.0 15 | 512 16 | 17 | 18 | true 19 | portable 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | false 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | 54 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/ConsoleApplication/CSharpConsoleApplication.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/vs/Xamarin.Windows.VisualStudio.Templates/CSharp/ConsoleApplication/CSharpConsoleApplication.ico -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/ConsoleApplication/CSharpConsoleApplication.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Console Application (Xamarin) 5 | A project for creating a fully Ahead-Of-Time compiled native command-line application in C#. 6 | CSharpConsoleApplication.ico 7 | CSharp 8 | 2.0 9 | 1000 10 | Xamarin.Windows.CSharp.ConsoleApplication 11 | true 12 | ConsoleApplication 13 | true 14 | 15 | 16 | 17 | AssemblyInfo.cs 18 | Program.cs 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/ConsoleApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace $safeprojectname$ 7 | { 8 | public class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/StaticLibrary/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("$projectname$")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("$registeredorganization$")] 12 | [assembly: AssemblyProduct("$projectname$")] 13 | [assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("$guid1$")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/StaticLibrary/CSharpStaticLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | $guid1$ 9 | Library 10 | Properties 11 | $safeprojectname$ 12 | $safeprojectname$ 13 | v$targetframeworkversion$ 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/StaticLibrary/CSharpStaticLibrary.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/vs/Xamarin.Windows.VisualStudio.Templates/CSharp/StaticLibrary/CSharpStaticLibrary.ico -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/StaticLibrary/CSharpStaticLibrary.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Static Library (Xamarin) 5 | A project for creating a fully Ahead-Of-Time compiled native static library in C# for embedding in C/C++ projects. 6 | CSharpStaticLibrary.ico 7 | CSharp 8 | 2.0 9 | 1000 10 | Xamarin.Windows.CSharp.StaticLibrary 11 | true 12 | StaticLibrary 13 | true 14 | 15 | 16 | 17 | AssemblyInfo.cs 18 | Class1.cs 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/CSharp/StaticLibrary/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace $safeprojectname$ 7 | { 8 | public class Class1 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Templates/Xamarin.Windows.VisualStudio.Templates.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 15.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 14.0 9 | 10 | 11 | publish\ 12 | true 13 | Disk 14 | false 15 | Foreground 16 | 7 17 | Days 18 | false 19 | false 20 | true 21 | 0 22 | 1.0.0.%2a 23 | false 24 | false 25 | true 26 | 27 | 28 | 29 | 30 | Debug 31 | AnyCPU 32 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 33 | {1B6299C6-4703-4FD5-B55E-BC47A4569A02} 34 | Library 35 | Properties 36 | Xamarin.Windows.VisualStudio.Templates 37 | Xamarin.Windows.VisualStudio.Templates 38 | v4.6 39 | 512 40 | false 41 | false 42 | false 43 | false 44 | false 45 | false 46 | false 47 | false 48 | false 49 | false 50 | 51 | 52 | true 53 | full 54 | false 55 | bin\Debug\ 56 | DEBUG;TRACE 57 | prompt 58 | 4 59 | 60 | 61 | pdbonly 62 | true 63 | bin\Release\ 64 | TRACE 65 | prompt 66 | 4 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Designer 77 | 78 | 79 | 80 | 81 | 82 | Windows\Xamarin AOT 83 | 84 | 85 | Windows\Xamarin AOT 86 | 87 | 88 | 89 | 90 | False 91 | Microsoft .NET Framework 4.5.2 %28x86 and x64%29 92 | true 93 | 94 | 95 | False 96 | .NET Framework 3.5 SP1 97 | false 98 | 99 | 100 | 101 | 102 | 109 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/vs/Xamarin.Windows.VisualStudio.Vsix/Key.snk -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/MSBuild.items: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/vs/Xamarin.Windows.VisualStudio.Vsix/MSBuild.items -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/ProjectExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.Shell; 3 | using Microsoft.VisualStudio.Shell.Interop; 4 | using EnvDTE; 5 | using Microsoft.VisualStudio; 6 | 7 | namespace EnvDTE 8 | { 9 | public static class ProjectExtensions 10 | { 11 | 12 | public static T GetPropertyValue(this Project project, int propertyId) where T : class { 13 | var hierarchy = project.ToHierarchy(); 14 | 15 | object propertyVal; 16 | if ((hierarchy.GetProperty(0, propertyId, out propertyVal) == VSConstants.S_OK)) 17 | return propertyVal as T; 18 | 19 | return null; 20 | } 21 | 22 | public static IVsHierarchy ToHierarchy(this Project project) { 23 | if (project == null) throw new ArgumentNullException("project"); 24 | 25 | try 26 | { 27 | IVsHierarchy hierarchy; 28 | var solutionService = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution2; 29 | if (solutionService.GetProjectOfUniqueName(project.UniqueName, out hierarchy) == VSConstants.S_OK) 30 | return hierarchy; 31 | } 32 | catch (NotImplementedException) 33 | { 34 | // ignore - apparently some Project implementations in Visual Studio do not implement the FileName property 35 | // and we'll get a NotImplemented exception thrown here. 36 | return null; 37 | } 38 | 39 | return null; 40 | } 41 | 42 | 43 | public static string GetMSBuildPropertyValue(this IVsBuildPropertyStorage storage, string property, string defaultValue) { 44 | string value = null; 45 | 46 | if (storage.GetPropertyValue(property, null, (uint)_PersistStorageType.PST_PROJECT_FILE, out value) == VSConstants.S_OK) 47 | return value; 48 | 49 | return defaultValue; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/ProjectPackageGuids.cs: -------------------------------------------------------------------------------- 1 | // 2 | // ProjectInterfaceConverters.cs 3 | // 4 | // Authors: 5 | // Jonathan Pobst 6 | // 7 | // Copyright 2010 Novell Inc. All rights reserved. 8 | // 9 | 10 | using System; 11 | 12 | namespace Xamarin.Windows 13 | { 14 | public class ProjectPageGuids 15 | { 16 | // Config Independent 17 | public static Guid CSharpBuildPage = new Guid("a54ad834-9219-4aa6-b589-607af21c3e26"); 18 | public static Guid DebugPage = new Guid("6185191f-1008-4fb2-a715-3a4e4f27e610"); 19 | public static Guid CodeAnalysisPage = new Guid("984ae51a-4b21-44e7-822c-dd5e046893ef"); 20 | 21 | // Config Dependent 22 | public static Guid BuildEventsPage = new Guid("1e78f8db-6c07-4d61-a18f-7514010abd56"); 23 | public static Guid CSharpApplicationPage = new Guid("5e9a8ac2-4f34-4521-858f-4c248ba31532"); 24 | public static Guid VBApplicationPage = new Guid("8998e48e-b89a-4034-b66e-353d8c1fdc2e"); 25 | public static Guid ServicesPage = new Guid("43e38d2e-43b8-4204-8225-9357316137a4"); 26 | public static Guid ReferencePathsPage = new Guid("031911c8-6148-4e25-b1b1-44bca9a0c45c"); // C# Only 27 | public static Guid SigningPage = new Guid("f8d6553f-f752-4dbf-acb6-f291b744a792"); 28 | public static Guid SecurityPage = new Guid("df8f7042-0bb1-47d1-8e6d-deb3d07698bd"); 29 | public static Guid PublishPage = new Guid("cc4014f5-b18d-439c-9352-f99d984cca85"); 30 | public static Guid MyExtensionsPage = new Guid("f24459fc-e883-4a8e-9da2-aef684f0e1f4"); 31 | 32 | // I don't know 33 | public static Guid VBWPFApplicationPage = new Guid("00aa1f44-2ba3-4eaa-b54a-ce18000e6c5d"); 34 | public static Guid ReferencesPage = new Guid("4e43f4ab-9f03-4129-95bf-b8ff870af6ab"); // VB Only 35 | public static Guid WPFSecurityPage = new Guid("00a2c8fe-3844-41be-9637-167454a7f1a7"); 36 | public static Guid VBCompilePage = new Guid("eda661ea-dc61-4750-b3a5-f6e9c74060f5"); 37 | public static Guid SqlDatabasePage = new Guid("87f6adce-9161-489f-907e-3930a6429609"); // SQL Server Projects 38 | public static Guid SqlDeployPage = new Guid("29ab1d1b-10e8-4511-a362-ef1571b8443c"); // SQL Server Projects 39 | public static Guid SmartDeviceDevicesPage = new Guid("7b74aadf-aca4-410e-8d4b-afe119835b99"); 40 | public static Guid SmartDeviceDebugPage = new Guid("ac5faec7-d452-4ac1-bc44-2d7ece6df06c"); 41 | public static Guid ResourceEditorPage = new Guid("ff4d6aca-9352-4a5f-821e-f4d6ebdcab11"); 42 | public static Guid SettingsDesignerPage = new Guid("6d2695f9-5365-4a78-89ed-f205c045bfe6"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Xamarin.Windows.VisualStudio.Vsix")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Xamarin.Windows.VisualStudio.Vsix")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion( 33 | ThisAssembly.Git.BaseVersion.Major + "." + 34 | ThisAssembly.Git.BaseVersion.Minor + "." + 35 | ThisAssembly.Git.BaseVersion.Patch + "." + 36 | ThisAssembly.Git.Commits)] 37 | [assembly: AssemblyInformationalVersion( 38 | ThisAssembly.Git.BaseVersion.Major + "." + 39 | ThisAssembly.Git.BaseVersion.Minor + "." + 40 | ThisAssembly.Git.BaseVersion.Patch + "." + 41 | ThisAssembly.Git.Commits + "-" + 42 | ThisAssembly.Git.Branch + "+" + 43 | ThisAssembly.Git.Commit)] 44 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/ReferenceAssemblies.items: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xamarin/xamarin-windows/079e4f6883879ba3fae734748ae4436b35300c49/vs/Xamarin.Windows.VisualStudio.Vsix/ReferenceAssemblies.items -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/XamarinWindowsConstants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Xamarin.Windows 8 | { 9 | class XamarinWindowsConstants 10 | { 11 | public readonly static string EnableAotModeProperty = "EnableAotMode"; 12 | public readonly static string BundleAssembliesProperty = "BundleAssemblies"; 13 | public readonly static string GenerateDebuggableAotModulesProperty = "GenerateDebuggableAotModules"; 14 | public readonly static string AdditionalAotArgumentsProperty = "AdditionalAotArguments"; 15 | public readonly static string AdditionalMonoOptionsProperty = "AdditionalMonoOptions"; 16 | public readonly static string MonoLogLevelProperty = "MonoLogLevel"; 17 | public readonly static string MonoLogMaskProperty = "MonoLogMask"; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/XamarinWindowsDebugLauncher.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Diagnostics; 5 | using System.IO; 6 | using System.Runtime.Remoting; 7 | using System.Runtime.Serialization.Formatters.Binary; 8 | using Microsoft.VisualStudio.Shell.Interop; 9 | using Mono.Debugging.Soft; 10 | using Microsoft.VisualStudio.Shell; 11 | using Mono.Debugging.VisualStudio; 12 | 13 | namespace Xamarin.Windows 14 | { 15 | internal class XamarinWindowsDebugLauncher : IDebugLauncher 16 | { 17 | private static readonly ITracer tracer = Tracer.Get(); 18 | 19 | public bool StartDebugger(SoftDebuggerSession session, StartInfo startInfo) 20 | { 21 | tracer.Verbose("Entering Launch for: {0}", this); 22 | var debugger = ServiceProvider.GlobalProvider.GetService(); 23 | 24 | var sessionMarshalling = new SessionMarshalling(session, startInfo); 25 | 26 | VsDebugTargetInfo4 info = new VsDebugTargetInfo4(); 27 | info.dlo = (uint)Microsoft.VisualStudio.Shell.Interop.DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; 28 | 29 | var startArgs = startInfo.StartArgs; 30 | var appName = "Mono"; 31 | if (startArgs is SoftDebuggerRemoteArgs) 32 | { 33 | appName = ((SoftDebuggerRemoteArgs)startArgs).AppName; 34 | } 35 | else if (startArgs is SoftDebuggerLaunchArgs) 36 | { 37 | appName = Path.GetFileNameWithoutExtension(startInfo.Command); 38 | } 39 | 40 | info.bstrExe = appName; 41 | info.bstrCurDir = ""; 42 | info.bstrArg = null; // no command line parameters 43 | info.bstrRemoteMachine = null; 44 | info.fSendToOutputWindow = 0; // Let stdout stay with the application. 45 | info.guidPortSupplier = Guids.PortSupplierGuid; 46 | info.guidLaunchDebugEngine = Guids.EngineGuid; 47 | info.bstrPortName = appName; 48 | 49 | using (MemoryStream ms = new MemoryStream()) 50 | { 51 | BinaryFormatter bf = new BinaryFormatter(); 52 | ObjRef oref = RemotingServices.Marshal(sessionMarshalling); 53 | bf.Serialize(ms, oref); 54 | info.bstrOptions = Convert.ToBase64String(ms.ToArray()); 55 | } 56 | 57 | try 58 | { 59 | var results = new VsDebugTargetProcessInfo[1]; 60 | debugger.LaunchDebugTargets4(1, new[] { info }, results); 61 | return true; 62 | } 63 | catch (Exception ex) 64 | { 65 | tracer.Error("Controller.Launch ()", ex); 66 | throw; 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/XamarinWindowsDebuggableConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Microsoft.VisualStudio.OLE.Interop; 5 | using Microsoft.VisualStudio.Shell.Interop; 6 | using System.Runtime.InteropServices; 7 | using Microsoft.VisualStudio; 8 | using Mono.Debugging.VisualStudio; 9 | using EnvDTE; 10 | using Mono.Debugging.Soft; 11 | using System.Net; 12 | 13 | namespace Xamarin.Windows 14 | { 15 | internal class XamarinWindowsDebuggableConfig : IVsDebuggableProjectCfg, IVsProjectFlavorCfg 16 | { 17 | private IVsProjectFlavorCfg baseProjectCfg; 18 | private Project baseProject; 19 | 20 | public XamarinWindowsDebuggableConfig(IVsProjectFlavorCfg pBaseProjectCfg, EnvDTE.Project project) 21 | { 22 | this.baseProject = project; 23 | this.baseProjectCfg = pBaseProjectCfg; 24 | } 25 | 26 | public int Close() 27 | { 28 | if (baseProjectCfg != null) 29 | { 30 | baseProjectCfg.Close(); 31 | baseProjectCfg = null; 32 | } 33 | 34 | return VSConstants.S_OK; 35 | } 36 | 37 | public int DebugLaunch(uint grfLaunch) 38 | {//if launch with debug; else just run 39 | var random = new Random(DateTime.Now.Millisecond); 40 | var port = 8800 + random.Next(0, 100); 41 | 42 | var startArgs = new SoftDebuggerListenArgs(baseProject.Name, IPAddress.Loopback, port); 43 | 44 | var startInfo = new XamarinWindowsStartInfo(startArgs, null, baseProject); 45 | var session = new XamarinWindowsDebuggerSession(); 46 | 47 | var launcher = new MonoDebuggerLauncher(new Progress(), new XamarinWindowsDebugLauncher()); 48 | 49 | launcher.StartSession(startInfo, session); 50 | 51 | return VSConstants.S_OK; 52 | } 53 | 54 | public int QueryDebugLaunch(uint grfLaunch, out int pfCanLaunch) 55 | { 56 | pfCanLaunch = 1; 57 | return VSConstants.S_OK; 58 | } 59 | 60 | public int get_CfgType(ref Guid iidCfg, out IntPtr ppCfg) 61 | { 62 | ppCfg = IntPtr.Zero; 63 | 64 | try 65 | { 66 | if (iidCfg == typeof(IVsDebuggableProjectCfg).GUID) 67 | ppCfg = Marshal.GetComInterfaceForObject(this, typeof(IVsDebuggableProjectCfg)); 68 | else if ((ppCfg == IntPtr.Zero) && (this.baseProjectCfg != null)) 69 | return this.baseProjectCfg.get_CfgType(ref iidCfg, out ppCfg); 70 | } 71 | catch (InvalidCastException) 72 | { 73 | } 74 | 75 | return VSConstants.S_OK; 76 | } 77 | 78 | public int EnumOutputs(out IVsEnumOutputs ppIVsEnumOutputs) 79 | { 80 | throw new NotImplementedException(); 81 | } 82 | 83 | public int get_BuildableProjectCfg(out IVsBuildableProjectCfg ppIVsBuildableProjectCfg) 84 | { 85 | throw new NotImplementedException(); 86 | } 87 | 88 | public int get_CanonicalName(out string pbstrCanonicalName) 89 | { 90 | throw new NotImplementedException(); 91 | } 92 | 93 | public int get_DisplayName(out string pbstrDisplayName) 94 | { 95 | throw new NotImplementedException(); 96 | } 97 | 98 | public int get_IsDebugOnly(out int pfIsDebugOnly) 99 | { 100 | throw new NotImplementedException(); 101 | } 102 | 103 | public int get_IsPackaged(out int pfIsPackaged) 104 | { 105 | throw new NotImplementedException(); 106 | } 107 | 108 | public int get_IsReleaseOnly(out int pfIsReleaseOnly) 109 | { 110 | throw new NotImplementedException(); 111 | } 112 | 113 | public int get_IsSpecifyingOutputSupported(out int pfIsSpecifyingOutputSupported) 114 | { 115 | throw new NotImplementedException(); 116 | } 117 | 118 | public int get_Platform(out Guid pguidPlatform) 119 | { 120 | throw new NotImplementedException(); 121 | } 122 | 123 | public int get_ProjectCfgProvider(out IVsProjectCfgProvider ppIVsProjectCfgProvider) 124 | { 125 | throw new NotImplementedException(); 126 | } 127 | 128 | public int get_RootURL(out string pbstrRootURL) 129 | { 130 | throw new NotImplementedException(); 131 | } 132 | 133 | public int get_TargetCodePage(out uint puiTargetCodePage) 134 | { 135 | throw new NotImplementedException(); 136 | } 137 | 138 | public int get_UpdateSequenceNumber(ULARGE_INTEGER[] puliUSN) 139 | { 140 | throw new NotImplementedException(); 141 | } 142 | 143 | public int OpenOutput(string szOutputCanonicalName, out IVsOutput ppIVsOutput) 144 | { 145 | throw new NotImplementedException(); 146 | } 147 | 148 | } 149 | } -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/XamarinWindowsDebuggerSession.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Mono.Debugging.Soft; 4 | using System; 5 | using Mono.Debugging.Client; 6 | using EnvDTE; 7 | using System.Diagnostics; 8 | using System.IO; 9 | using Microsoft.VisualStudio.Setup.Configuration; 10 | using Microsoft.VisualStudio.Shell.Interop; 11 | using Clide; 12 | using Xamarin.Windows.Properties; 13 | using Microsoft.VisualStudio; 14 | 15 | namespace Xamarin.Windows 16 | { 17 | class XamarinWindowsDebuggerSession : SoftDebuggerSession 18 | { 19 | // The GUID of Microsoft.VisualStudio.Setup.Configuration.SetupConfigurationClass 20 | private readonly Guid SetupConfigurationClassGuid = new Guid("177F0C4A-1CD3-4DE7-A32C-71DBBB9FA36D"); 21 | private System.Diagnostics.Process process; 22 | private string installPath = null; 23 | 24 | protected override void OnRun(DebuggerStartInfo startInfo) 25 | { 26 | base.OnRun(startInfo); 27 | UseOperationThread = true; 28 | Project startupProject = ((Mono.Debugging.VisualStudio.StartInfo)startInfo).StartupProject; 29 | 30 | IVsHierarchy hierarchy = startupProject.ToHierarchy(); 31 | IProjectNode node = startupProject.AsProjectNode(); 32 | BuildPropertyStorage storage = new BuildPropertyStorage(hierarchy, node.Configuration.ActiveConfigurationName); 33 | 34 | var enableAotMode = storage.GetPropertyValue(XamarinWindowsConstants.EnableAotModeProperty); 35 | var bundleAsemblies = storage.GetPropertyValue(XamarinWindowsConstants.BundleAssembliesProperty); 36 | var generateDebuggableAotModules = storage.GetPropertyValue(XamarinWindowsConstants.GenerateDebuggableAotModulesProperty); 37 | var additionalMonoOptions = storage.GetPropertyValue(XamarinWindowsConstants.AdditionalMonoOptionsProperty)?.Trim(); 38 | var monoLogLevel = storage.GetPropertyValue(XamarinWindowsConstants.MonoLogLevelProperty); 39 | var monoLogMask = storage.GetPropertyValue(XamarinWindowsConstants.MonoLogMaskProperty); 40 | 41 | var startArguments = startupProject.ConfigurationManager.ActiveConfiguration.Properties.Item("StartArguments").Value.ToString(); 42 | var assemblyPath = GetOutputAssembly(startupProject, enableAotMode, generateDebuggableAotModules); 43 | var monoDirectory = Path.Combine(GetInstallPath(), @"MSBuild\Xamarin\Windows\x64\Release"); 44 | var monoPath = Path.Combine(GetInstallPath(), @"Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.Windows\v1.0"); 45 | var args = ((Mono.Debugging.VisualStudio.StartInfo)startInfo).StartArgs as SoftDebuggerListenArgs; 46 | 47 | process = new System.Diagnostics.Process(); 48 | var workingDirectory = Path.GetDirectoryName(assemblyPath); 49 | var monoOptions = $"--debug --debugger-agent=transport=dt_socket,address=127.0.0.1:{args.DebugPort}"; 50 | if (!string.IsNullOrEmpty(additionalMonoOptions)) 51 | monoOptions += " " + additionalMonoOptions; 52 | 53 | if (!enableAotMode) 54 | { 55 | process.StartInfo = new ProcessStartInfo(Path.Combine(monoDirectory, "mono-sgen.exe"), monoOptions + $" \"{assemblyPath}\" {startArguments}".TrimEnd()); 56 | } 57 | else 58 | { 59 | IVsBuildPropertyStorage buildPropertyStorage = (IVsBuildPropertyStorage)hierarchy; 60 | string nativeProjectName = buildPropertyStorage.GetMSBuildPropertyValue("_XWNativeProjectName", null); 61 | var launcherExe = Path.Combine(workingDirectory, nativeProjectName + ".exe"); 62 | process.StartInfo = new ProcessStartInfo(launcherExe, startArguments); 63 | process.StartInfo.EnvironmentVariables["MONO_BUNDLED_OPTIONS"] = monoOptions; 64 | } 65 | process.StartInfo.WorkingDirectory = workingDirectory; 66 | process.StartInfo.UseShellExecute = false; 67 | if (!string.IsNullOrEmpty(monoLogLevel)) 68 | process.StartInfo.EnvironmentVariables["MONO_LOG_LEVEL"] = monoLogLevel; 69 | if (!string.IsNullOrEmpty(monoLogMask)) 70 | process.StartInfo.EnvironmentVariables["MONO_LOG_MASK"] = monoLogMask; 71 | 72 | process.StartInfo.EnvironmentVariables["MONO_PATH"] = monoPath; 73 | process.Start(); 74 | } 75 | 76 | private string GetInstallPath() 77 | { 78 | if (installPath == null) { 79 | var config = (ISetupConfiguration2) Activator.CreateInstance(Type.GetTypeFromCLSID(SetupConfigurationClassGuid)); 80 | var instance = config.GetInstanceForCurrentProcess(); 81 | installPath = instance.GetInstallationPath(); 82 | } 83 | return installPath; 84 | } 85 | 86 | private string GetOutputAssembly(Project startupProject, bool enableAotMode, bool generateDebuggableAotModules) 87 | { 88 | var baseFolder = startupProject.Properties.Item("FullPath").Value.ToString(); 89 | var outFolder = startupProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString(); 90 | var assemblyName = startupProject.Properties.Item("OutputFileName").Value.ToString(); 91 | 92 | if (enableAotMode && generateDebuggableAotModules) 93 | outFolder = Path.Combine(outFolder, "Aotd"); 94 | else if (enableAotMode) 95 | outFolder = Path.Combine(outFolder, "Aot"); 96 | 97 | return Path.Combine(baseFolder, outFolder, assemblyName); 98 | } 99 | 100 | protected override void OnExit() 101 | { 102 | if (!process.HasExited) 103 | process.Kill(); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/XamarinWindowsFlavoredProject.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Microsoft.VisualStudio.Shell.Flavor; 5 | using Microsoft.VisualStudio.Shell.Interop; 6 | using Microsoft.VisualStudio; 7 | using System.Runtime.InteropServices; 8 | using Xamarin.Windows.Properties; 9 | using System.Linq; 10 | 11 | namespace Xamarin.Windows 12 | { 13 | internal class XamarinWindowsFlavoredProject : FlavoredProjectBase, IVsProjectFlavorCfgProvider 14 | { 15 | /// 16 | /// A space-delimited list of the project's capabilities. This property is optional. 17 | /// 18 | /// 19 | /// Value from __VSHPROPID5, which only exists on dev11+ and is used to express support 20 | /// for the new shared projects. 21 | /// 22 | const int VSHPROPID_ProjectCapabilities = -2124; 23 | 24 | private IVsProjectFlavorCfgProvider innerFlavorConfig; 25 | private XamarinWindowsPackage package; 26 | 27 | public XamarinWindowsFlavoredProject(XamarinWindowsPackage package) 28 | { 29 | this.package = package; 30 | } 31 | 32 | public int CreateProjectFlavorCfg(IVsCfg pBaseProjectCfg, out IVsProjectFlavorCfg ppFlavorCfg) 33 | { 34 | Console.WriteLine("CreateProjectFlavorcfg"); 35 | 36 | IVsProjectFlavorCfg cfg = null; 37 | ppFlavorCfg = null; 38 | 39 | if (innerFlavorConfig != null) 40 | { 41 | object project; 42 | GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out project); 43 | 44 | this.innerFlavorConfig.CreateProjectFlavorCfg(pBaseProjectCfg, out cfg); 45 | ppFlavorCfg = new XamarinWindowsDebuggableConfig(cfg, project as EnvDTE.Project); 46 | } 47 | 48 | if (ppFlavorCfg != null) 49 | return VSConstants.S_OK; 50 | Console.WriteLine("Failing CreateProjectFlavorcfg"); 51 | return VSConstants.E_FAIL; 52 | } 53 | 54 | protected override void SetInnerProject(IntPtr innerIUnknown) 55 | { 56 | object inner = null; 57 | 58 | inner = Marshal.GetObjectForIUnknown(innerIUnknown); 59 | innerFlavorConfig = inner as IVsProjectFlavorCfgProvider; 60 | 61 | if (base.serviceProvider == null) 62 | base.serviceProvider = this.package; 63 | 64 | base.SetInnerProject(innerIUnknown); 65 | } 66 | 67 | 68 | protected override int GetProperty(uint itemId, int propId, out object property) { 69 | //Use propId to filter configuration-dependent property pages. 70 | switch ((__VSHPROPID2)propId) 71 | { 72 | case __VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList: 73 | case __VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList: 74 | { 75 | // Get a semicolon-delimited list of clsids of property pages. 76 | ErrorHandler.ThrowOnFailure(base.GetProperty(itemId, propId, out property)); 77 | var ids = ((string)property).Split(';').Select(Guid.Parse).ToList(); 78 | 79 | if ((__VSHPROPID2)propId == __VSHPROPID2.VSHPROPID_CfgPropertyPagesCLSIDList) 80 | { 81 | // Add our property page. 82 | ids.Add(typeof(OptionsPage).GUID); 83 | } 84 | 85 | property = string.Join(";", ids.Select(g => g.ToString("B"))); 86 | return VSConstants.S_OK; 87 | } 88 | case __VSHPROPID2.VSHPROPID_PriorityPropertyPagesCLSIDList: 89 | { 90 | // Get a semicolon-delimited list of clsids of property pages. 91 | ErrorHandler.ThrowOnFailure(base.GetProperty(itemId, propId, out property)); 92 | var ids = ((string)property).Split(';').Select(Guid.Parse).ToList(); 93 | // Move our Options page to the top 94 | ids.Remove(typeof(OptionsPage).GUID); 95 | ids.Insert(0, typeof(OptionsPage).GUID); 96 | property = string.Join(";", ids.Select(g => g.ToString("B"))); 97 | return VSConstants.S_OK; 98 | } 99 | } 100 | if (propId == VSHPROPID_ProjectCapabilities) 101 | { 102 | // First grab whatever capabilities our base project has. 103 | if (base.GetProperty(itemId, propId, out property) == VSConstants.S_OK && property != null) 104 | property = ((string)property) + " SharedProjectReferences"; 105 | else 106 | property = "SharedProjectReferences"; 107 | 108 | return VSConstants.S_OK; 109 | } 110 | 111 | return base.GetProperty(itemId, propId, out property); 112 | } 113 | 114 | } 115 | } -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/XamarinWindowsPackage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.ComponentModel.Design; 5 | using System.Diagnostics; 6 | using System.Diagnostics.CodeAnalysis; 7 | using System.Globalization; 8 | using System.Runtime.InteropServices; 9 | using Microsoft.VisualStudio; 10 | using Microsoft.VisualStudio.OLE.Interop; 11 | using Microsoft.VisualStudio.Shell; 12 | using Microsoft.VisualStudio.Shell.Interop; 13 | using Microsoft.Win32; 14 | using Mono.Debugging.Client; 15 | using Xamarin.Windows.Properties; 16 | 17 | namespace Xamarin.Windows 18 | { 19 | /// 20 | /// This is the class that implements the package exposed by this assembly. 21 | /// 22 | /// 23 | /// 24 | /// The minimum requirement for a class to be considered a valid package for Visual Studio 25 | /// is to implement the IVsPackage interface and register itself with the shell. 26 | /// This package uses the helper classes defined inside the Managed Package Framework (MPF) 27 | /// to do it: it derives from the Package class that provides the implementation of the 28 | /// IVsPackage interface and uses the registration attributes defined in the framework to 29 | /// register itself and its components with the shell. These attributes tell the pkgdef creation 30 | /// utility what data to put into .pkgdef file. 31 | /// 32 | /// 33 | /// To get loaded into VS, the package must be referred by <Asset Type="Microsoft.VisualStudio.VsPackage" ...> in .vsixmanifest file. 34 | /// 35 | /// 36 | [PackageRegistration(UseManagedResourcesOnly = true)] 37 | [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About 38 | [Guid(XamarinWindowsPackage.PackageGuidString)] 39 | [ProvideProjectFactory(typeof (XamarinWindowsProjectFactory), "Xamarin.Windows", null, null, null, null, LanguageVsTemplate = "CSharp", TemplateGroupIDsVsTemplate = "Xamarin.Windows")] 40 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")] 41 | public sealed class XamarinWindowsPackage : Package 42 | { 43 | /// 44 | /// XamarinWindowsPackage GUID string. 45 | /// 46 | public const string PackageGuidString = "0610d5ad-36f3-4a90-a0ba-55736bf813ba"; 47 | public const string XamarinWindowsProjectGuid = "8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED"; 48 | 49 | /// 50 | /// Initializes a new instance of the class. 51 | /// 52 | public XamarinWindowsPackage() 53 | { 54 | // Inside this method you can place any initialization code that does not require 55 | // any Visual Studio service because at this point the package object is created but 56 | // not sited yet inside Visual Studio environment. The place to do all the other 57 | // initialization is the Initialize method. 58 | } 59 | 60 | #region Package Members 61 | 62 | /// 63 | /// Initialization of the package; this method is called right after the package is sited, so this is the place 64 | /// where you can put all the initialization code that rely on services provided by VisualStudio. 65 | /// 66 | protected override void Initialize() 67 | { 68 | base.Initialize(); 69 | 70 | RegisterProjectFactory(new XamarinWindowsProjectFactory(this)); 71 | 72 | DebuggerLoggingService.CustomLogger = new NullLogger(); 73 | } 74 | 75 | #endregion 76 | } 77 | 78 | class NullLogger : ICustomLogger 79 | { 80 | public string GetNewDebuggerLogFilename() 81 | { 82 | return null; 83 | } 84 | 85 | public void LogAndShowException(string message, Exception ex) 86 | { 87 | } 88 | 89 | public void LogError(string message, Exception ex) 90 | { 91 | } 92 | 93 | public void LogMessage(string messageFormat, params object[] args) 94 | { 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/XamarinWindowsProject.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Microsoft.VisualStudio.Shell.Interop; 4 | using System.Runtime.InteropServices; 5 | using Microsoft.VisualStudio.OLE.Interop; 6 | using System; 7 | using Microsoft.VisualStudio.Shell; 8 | using Microsoft.VisualStudio.Shell.Flavor; 9 | 10 | namespace Xamarin.Windows 11 | { 12 | [ComVisible(false)] 13 | [Guid(XamarinWindowsPackage.XamarinWindowsProjectGuid)] 14 | public class XamarinWindowsProjectFactory : FlavoredProjectFactoryBase 15 | { 16 | private XamarinWindowsPackage package; 17 | 18 | public XamarinWindowsProjectFactory(XamarinWindowsPackage package) 19 | { 20 | this.package = package; 21 | } 22 | 23 | protected override object PreCreateForOuter(IntPtr outerProjectIUnknown) 24 | { 25 | return new XamarinWindowsFlavoredProject(package); 26 | } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/XamarinWindowsStartInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using EnvDTE; 4 | using Mono.Debugging.Soft; 5 | using Mono.Debugging.VisualStudio; 6 | 7 | namespace Xamarin.Windows 8 | { 9 | internal class XamarinWindowsStartInfo : StartInfo 10 | { 11 | public XamarinWindowsStartInfo(SoftDebuggerStartArgs args, DebuggingOptions options, Project startupProject) : base(args, options, startupProject) 12 | { 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /vs/Xamarin.Windows.VisualStudio.Vsix/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Xamarin SDK for Windows 6 | Enables development of native Windows applications in C# using Xamarin's Ahead-Of-Time compiler. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | --------------------------------------------------------------------------------