Enable experimental usage of Microsoft.ReactNative.Managed as a nuget package (#5283)

* Enable experimental usage of Microsoft.ReactNative.Managed as a nuget package

* Change files

* Add fallback logic for different configurations
This commit is contained in:
dannyvv 2020-07-06 20:16:24 -07:00 коммит произвёл GitHub
Родитель 4b4fedc5f4
Коммит 5570885a65
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
26 изменённых файлов: 516 добавлений и 194 удалений

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

@ -166,7 +166,9 @@ jobs:
parameters:
artifactName: ReactWindows
layoutHeaders: eq('true', variables['LayoutHeaders'])
contents: Microsoft.ReactNative\**
contents: |
Microsoft.ReactNative\**
Microsoft.ReactNative.Managed\**
# Disable for now, not sure this works on github projects anyway.
# - task: PublishSymbols@2

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

@ -7,7 +7,8 @@ parameters:
microsoftRNId: 'Microsoft.ReactNative'
slices: '("x64.Release", "x64.Debug", "x86.Release", "x86.Debug", "ARM.Release", "ARM.Debug", "ARM64.Release", "ARM64.Debug")'
packDesktop: true
packMicrosoft: true
packMicrosoftReactNative: true
packMicrosoftReactNativeManaged: true
steps:
- task: DownloadBuildArtifacts@0
@ -16,31 +17,26 @@ steps:
artifactName: ReactWindows
downloadPath: $(System.DefaultWorkingDirectory)
# Strip down the binaries from nuget because we may not have built all the flavours.
- task: PowerShell@2
displayName: Strip slices from Microsoft.ReactNative.nuspec
inputs:
targetType: filePath
filePath: $(System.DefaultWorkingDirectory)\ReactWindows\StripAdditionalPlatformsFromNuspec.ps1
arguments: -nuspec $(System.DefaultWorkingDirectory)/ReactWindows/Microsoft.ReactNative.nuspec -outfile $(System.DefaultWorkingDirectory)/ReactWindows/Microsoft.ReactNative.nuspec -slices ("x64.Release", "x86.Debug", "ARM.Release")
condition: and(succeeded(), ${{ parameters.packMicrosoft }})
- ${{ if eq(parameters.packDesktop, true) }}:
- template: prep-and-pack-single.yml
parameters:
packageId: ${{parameters.desktopId}}
packageVersion: ${{parameters.npmVersion}}
slices: ''
buildProperties: 'CommitId=${{parameters.publishCommitId}};nugetroot=${{parameters.nugetroot}}'
- task: NuGetCommand@2
displayName: 'NuGet pack Desktop'
inputs:
command: pack
verbosityPack: 'Detailed'
packagesToPack: $(System.DefaultWorkingDirectory)/ReactWindows/ReactWin32.nuspec
packDestination: $(System.DefaultWorkingDirectory)/NugetRootFinal
buildProperties: CommitId=${{parameters.publishCommitId}};version=${{parameters.npmVersion}};id=${{parameters.desktopId}};nugetroot=${{parameters.nugetroot}}
condition: and(succeeded(), ${{ parameters.packDesktop }})
- ${{ if eq(parameters.packMicrosoftReactNative, true) }}:
- template: prep-and-pack-single.yml
parameters:
packageId: Microsoft.ReactNative
packageVersion: ${{parameters.npmVersion}}
slices: ${{ parameters.slices }}
buildProperties: CommitId=${{parameters.publishCommitId}};nugetroot=${{parameters.nugetroot}};baseconfiguration=Release;baseplatform=x64
- task: NuGetCommand@2
displayName: 'NuGet pack Microsoft.ReactNative'
inputs:
command: pack
verbosityPack: 'Detailed'
packagesToPack: $(System.DefaultWorkingDirectory)/ReactWindows/Microsoft.ReactNative.nuspec
packDestination: $(System.DefaultWorkingDirectory)/NugetRootFinal
buildProperties: CommitId=${{parameters.publishCommitId}};version=${{parameters.npmVersion}};id=${{parameters.microsoftRNId}};nugetroot=${{parameters.nugetroot}};baseconfiguration=Release;baseplatform=x64
condition: and(succeeded(), ${{ parameters.packMicrosoft }})
- ${{ if eq(parameters.packMicrosoftReactNativeManaged, true) }}:
- template: prep-and-pack-single.yml
parameters:
packageId: Microsoft.ReactNative.Managed
packageVersion: ${{parameters.npmVersion}}
slices: ${{ parameters.slices }}
buildProperties: CommitId=${{parameters.publishCommitId}};nugetroot=${{parameters.nugetroot}};baseconfiguration=Release;baseplatform=x64

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

@ -0,0 +1,34 @@
parameters:
packageId: ''
packageVersion: ''
slices: ''
buildProperties: ''
steps:
# Strip down the binaries from NuGet because we may not have built all the flavours.
- task: PowerShell@2
displayName: '${{ parameters.packageId }} - Strip slices from nuspec'
inputs:
targetType: filePath
filePath: $(System.DefaultWorkingDirectory)\ReactWindows\StripAdditionalPlatformsFromNuspec.ps1
arguments: -nuspec $(System.DefaultWorkingDirectory)/ReactWindows/${{parameters.packageId}}.nuspec -outfile $(System.DefaultWorkingDirectory)/ReactWindows/${{parameters.packageId}}.nuspec -slices ${{ parameters.slices }} -debug
condition: and(succeeded(), ne('', '${{ parameters.slices }}'))
- task: NuGetCommand@2
displayName: '${{ parameters.packageId }} - Nuget pack'
inputs:
command: pack
verbosityPack: 'Detailed'
packagesToPack: $(System.DefaultWorkingDirectory)/ReactWindows/${{ parameters.packageId }}.nuspec
packDestination: $(System.DefaultWorkingDirectory)/NugetRootFinal
buildProperties: version=${{ parameters.packageVersion }};id=${{ parameters.packageId }};${{ parameters.buildProperties }}
- task: CmdLine@2
displayName: '${{ parameters.packageId }} - Nuget push to local test feed'
inputs:
script: |
set TestFeed=$(System.DefaultWorkingDirectory)\NugetTestFeed
if NOT EXIST %TestFeed% (mkdir %TestFeed%)
nuget add $(System.DefaultWorkingDirectory)\NugetRootFinal\${{ parameters.packageId }}.${{ parameters.packageVersion }}.nupkg -Source %TestFeed%
workingDirectory: packages/microsoft-reactnative-sampleapps

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

@ -4,7 +4,7 @@ parameters:
version:
platform:
configuration:
experimentalNuGetDependency: false
useNuGet: false
vsComponents: ''
listVsComponents: false
installVsComponents: false
@ -53,12 +53,19 @@ steps:
inputs:
versionSpec: ">=4.6.0"
- task: DownloadBuildArtifacts@0
displayName: 'Download TestMSRNNuget Artifact'
inputs:
artifactName: TestMSRNNuget.${{ parameters.platform }}.${{ parameters.configuration }}
downloadPath: $(System.DefaultWorkingDirectory)
condition: and(succeeded(), eq('true', ${{ parameters.experimentalNuGetDependency }}))
- ${{ if eq(parameters.useNuGet, true) }}:
- task: DownloadBuildArtifacts@0
displayName: 'Download Nuget Test Feed'
inputs:
artifactName: NuGetTestFeed
downloadPath: $(System.DefaultWorkingDirectory)
- script: |
echo ##vso[task.setvariable variable=nugetInitArguments]--experimentalNugetDependency true --nuGetTestFeed $(System.DefaultWorkingDirectory)\NuGetTestFeed --nuGetTestVersion ${{ parameters.version }}
displayName: 'Configure additional args for nuget'
- ${{ if not(eq(parameters.useNuGet, true)) }}:
- script: |
echo ##vso[task.setvariable variable=nugetInitArguments]
displayName: 'No additional args for nuget'
# We force the usage of npm instead of yarn becuase yarn has fragility issues when redirected to a different server (such as verdaccio)
- task: CmdLine@2
@ -70,29 +77,9 @@ steps:
- task: CmdLine@2
displayName: Apply windows template
inputs:
script: npx react-native-windows-init --verbose --version $(npmTag) --overwrite --language ${{ parameters.language }} --experimentalNuGetDependency ${{ parameters.experimentalNuGetDependency }} ${{ parameters.additionalInitArguments }}
script: npx react-native-windows-init --verbose --version $(npmTag) --overwrite --language ${{ parameters.language }} ${{ parameters.additionalInitArguments }} $(nugetInitArguments)
workingDirectory: $(Agent.BuildDirectory)\testcli
- task: PowerShell@2
displayName: Install private Microsoft.ReactNative package
inputs:
targetType: inline
script: |
Install-Package Microsoft.ReactNative -Source $(System.DefaultWorkingDirectory)/TestMSRNNuget.${{ parameters.platform }}.${{ parameters.configuration }} -Destination $(Agent.BuildDirectory)\testcli\localNugets
$xml = [xml](gc $(Agent.BuildDirectory)\testcli\windows\Nuget.Config)
$newSource = $xml.CreateElement("add");
$keyAttr = $xml.CreateAttribute("key");
$keyAttr.Value ="PrPublish";
$valueAttr = $xml.CreateAttribute("value");
$valueAttr.Value ="$(Agent.BuildDirectory)\testcli\localNugets";
$newSource.Attributes.Append($keyAttr);
$newSource.Attributes.Append($valueAttr);
$packageSources = $xml.ChildNodes.Item(1).packageSources;
$packageSources.InsertBefore($newSource, $packageSources.FirstChild);
$xml.save("$(Agent.BuildDirectory)\testcli\windows\Nuget.Config");
condition: and(succeeded(), eq('true', ${{ parameters.experimentalNuGetDependency }}))
- task: PowerShell@2
displayName: List Visual Studio Components
inputs:
@ -110,29 +97,22 @@ steps:
-Cleanup:$true
condition: and(succeeded(), ${{ parameters.installVsComponents }})
# Work around issue of parameters not getting expanded in conditions properly
- powershell: |
Write-Host "##vso[task.setvariable variable=localConfig]${{ parameters.configuration}}"
- ${{ if not(eq(parameters.configuration, 'Release')) }}:
- script: |
echo ##vso[task.setvariable variable=releaseBuildArgs]--release
displayName: 'Configure extra args for Build project'
- task: CmdLine@2
displayName: Build project (Release)
displayName: Build project
inputs:
script: npx --no-install react-native run-windows --arch ${{ parameters.platform }} --no-launch --no-deploy --logging --buildLogDirectory $(Build.BinariesDirectory)\$(platform)\$(configuration)\BuildLogs --release
script: npx --no-install react-native run-windows --arch ${{ parameters.platform }} --no-launch --no-deploy --logging --buildLogDirectory $(Build.BinariesDirectory)\${{ parameters.platform }}\${{ parameters.configuration }}\BuildLogs $(releaseBuildArgs)
workingDirectory: $(Agent.BuildDirectory)\testcli
condition: and(succeeded(), eq('Release', variables['localConfig']))
- task: CmdLine@2
displayName: Build project (Debug)
inputs:
script: npx --no-install react-native run-windows --arch ${{ parameters.platform }} --no-launch --no-deploy --logging --buildLogDirectory $(Build.BinariesDirectory)\$(platform)\$(configuration)\BuildLogs
workingDirectory: $(Agent.BuildDirectory)\testcli
condition: and(succeeded(), eq('Debug', variables['localConfig']))
- task: PublishBuildArtifacts@1
displayName: Upload build logs
condition: succeededOrFailed()
inputs:
pathtoPublish: '$(Build.BinariesDirectory)\$(platform)\$(configuration)\BuildLogs'
inputs:
pathtoPublish: '$(Build.BinariesDirectory)\${{ parameters.platform }}\${{ parameters.configuration }}\BuildLogs'
artifactName: 'Build logs - $(Agent.JobName)'
- task: CmdLine@2

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

@ -39,7 +39,6 @@ jobs:
X86Debug:
BuildConfiguration: Debug
BuildPlatform: x86
TestMSRNNuget: true
LayoutHeaders: true
#X86Release:
# BuildConfiguration: Release
@ -143,30 +142,7 @@ jobs:
layoutHeaders: eq('true', variables['LayoutHeaders'])
contents: |
Microsoft.ReactNative\**
- script: |
npx --no-install beachball bump --branch origin/$(System.PullRequest.TargetBranch)
displayName: Bump package versions to align NuGet version with npm version
condition: eq('true', variables['TestMSRNNuget'])
- task: PowerShell@2
displayName: Prepare minimum NuGet for testing experimental init
inputs:
targetType: 'inline'
script: |
$pkgJson = Get-Content -Raw -Path .\vnext\package.json | ConvertFrom-Json
$pkgVersion = $pkgJson.version
$(Build.SourcesDirectory)\vnext\Scripts\StripAdditionalPlatformsFromNuspec.ps1 -slices ("$(BuildPlatform).$(BuildConfiguration)")
Copy-Item -Force -Path vnext\Scripts\Microsoft.ReactNative.targets -Destination $(Build.SourcesDirectory)\vnext\target
nuget pack $(Build.SourcesDirectory)\vnext\Scripts\Microsoft.ReactNative.PR.nuspec -NonInteractive -OutputDirectory $(Build.StagingDirectory)/TestMSRNNuget -Properties "Configuration=Release;CommitId=0;version=$pkgVersion;id=Microsoft.ReactNative;nugetroot=$(Build.StagingDirectory);baseplatform=$(BuildPlatform);baseconfiguration=$(BuildConfiguration)" -Verbosity Detailed
condition: eq('true', variables['TestMSRNNuget'])
- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: TestMSRNNuget"
inputs:
artifactName: TestMSRNNuget.$(BuildPlatform).$(BuildConfiguration)
pathtoPublish: $(Build.StagingDirectory)/TestMSRNNuget
condition: eq('true', variables['TestMSRNNuget'])
Microsoft.ReactNative.Managed\**
- job: RNW_WinUI3
displayName: WinUI3 Playground
@ -598,26 +574,33 @@ jobs:
displayName: Verify react-native init experimental
dependsOn:
- Setup
- RNWUniversalPR
- RNWNugetPR
condition: |
and
(
ne( dependencies.Setup.outputs['checkPayload.shouldSkipPRBuild'], 'True' ),
in(dependencies.RNWUniversalPR.result, 'Succeeded', 'SucceededWithIssues', 'Skipped')
in(dependencies.RNWNugetPR.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'),
in(dependencies.RNWUniversalPR.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'),
in(dependencies.RNWDesktopPR.result, 'Succeeded', 'SucceededWithIssues', 'Skipped')
)
timeoutInMinutes: 40 # how long to run the job before automatically cancelling
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
pool:
vmImage: $(VmImage)
strategy:
matrix:
cpp:
Language: cpp
cs:
Language: cs
steps:
- template: templates/react-native-init.yml
parameters:
language: cpp
language: $(Language)
configuration: Debug
platform: x86
version: $(reactNativeVersion)
additionalInitArguments: ${{ '' }}
experimentalNuGetDependency: true
useNuGet: true
- job: RNWExtraChecks
displayName: Extra Checks
@ -720,5 +703,11 @@ jobs:
- template: templates/prep-and-pack-nuget.yml
parameters:
slices: '("x64.Release", "x86.Debug", "ARM.Debug")'
packUniversal: false
slices: '("x64.Release", "x86.Debug", "ARM.Release")'
npmVersion: $(reactNativeVersion)
- task: PublishBuildArtifacts@1
displayName: Upload PR NuGet Test feed
inputs:
pathtoPublish: $(System.DefaultWorkingDirectory)/NuGetTestFeed
artifactName: NuGetTestFeed

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

@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Enable experimental usage of Microsoft.ReactNative.Managed as a nuget package",
"packageName": "react-native-windows",
"email": "dannyvv@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-07-02T19:40:34.030Z"
}

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

@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Enable experimental usage of Microsoft.ReactNative.Managed as a nuget package",
"packageName": "react-native-windows-init",
"email": "dannyvv@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-07-02T19:40:32.580Z"
}

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

@ -0,0 +1,76 @@
## Testing NuGet package for new react-native init templates.
Today's default is to use the C++ and C# code from the `react-native-windows` npm package as source. We have been working on moving to a binary distribution model for this code via NuGet.
Today we support the following projects as a NuGet package:
* Microsoft.ReactNative
* Microsoft.ReactNative.Managed
Testing NuGet packages is frequently a painful process as msbuild and NuGet lack referential transparency. The steps in this document hope to alleviate some of the challenges.
## Complicating factors
* NuGet packages can only be loaded from a feed
> These scripts help maintain a test feed on your local disk
* Each change requires a version bump.
NuGet caches by directory and simply checks if a directory with that version exists, regardless of whether the package has changed. It has implicit assumptions all up its stack that versions are immutable. Therefore each time you create a new package, you are forced to bump the versionpackage, you are forced to bupm the version
* UWP NuGet packages contain multiple slices specific for each platform.
> These scripts allow you to filter to specific slices so you don't have to build all flavors
## Steps
1. Decide which slices you want. The default is a single slice `'Debug,X64'` but more are supported.
1. Decide on the version scheme. Recommended is: `0.0.1-dannyvv001` and keeping bumping the last 3 digigs
1. Build the bits in your repo for slice you selected
1. open terminal for your enlistment (in vs dev prompt if you haven't setup your box otherwise)
1. yarn
1. yarn build
1. pushd vnext
1. NuGet restore Microsoft.ReactNative.sln
1. msbuild Microsoft.ReactNative.sln /bl /m /p:Configuration=Debug /p:Platform=x64
1. Repeat the preivous msbuild step for any other slices you might want to include
1. Publish the NuGet packages
1. open terminal for your enlistment
1. `vnext\Scripts\PublishNuGetPackagesLocally.cmd 0.0.1-MyTest001`
> See below for a breakdown of the arguments
1. Link your repo for fast CLI testing
1. open terminal for your enlsitment
1. push vnext
1. yarn link
> if it fails with already being registred for anotehr enlistment you can run `yarn unlink`
1. Generate a test project
1. open terminal in a test folder
1. `npx react-native init MyProj`
1. cd `MyProj`
1. Apply the react-native-windows template:
1. `node z:\src\r3\packages\react-native-windows-init\lib-commonjs\Cli.js --version 0.0.0 --useDevMode --overwrite --language cs --experimentalNugetDependency --nuGetTestFeed c:\temp\RnWNuGetTesting\feed --nuGetTestVersion 0.0.1-MyTest001 `
> See below for a breakdown of the arguments:
1. Do your testing
## Changes:
* Changes to the binaries in the NuGet package
1. Rerun the builds for the slices you use
1. Rerun publish NuGet script bumping the version number by one
1. Reapply the windows template with the new version number
1. Do your tests
* Change to the template generation
1. yarn build
1. Reapply the windows template
1. Do your tests
## Scripts
### PublishNugetPackagesLocally
This script takes more options for more customization: `<version> [<targetDir>] [<slices>] [<baseConfiguration>] [<basePlatform>]`.
Let's break down all arguments:
* `targetDir`: Where the packages and feed should be placed. Default is `c:\temp\RnWNugetTesting`
* `slices`: This is the set of slices to produce in powershell array syntax. The default is: `@('x64.Debug')`. An example of more slices would be: `@('x64.Debug', 'X86.Release', 'ARM64.Release')`
* `baseConfiguration`: The slice that is used for the non configuration specific build outputs. Default is: `Debug`
* `basePlatform`: The slice that is used for the non platform specific build outputs. Default is `x64`
### react-native-windows-init ... cli.js
This script has many options, but let's break down the ones from the sample:
* `--version 0.0.0 --useDevMode`: The version doesn't matter when using dev mode, which means that the npm package is used that is registred as the dev package using `yarn link` per instructions above. This saves copying all the output files to your package directory, to your yarn cache. It is also a lot faster and since it is a link, you can make changes to your enlistment i.e. to `vnext\StyleSheets` and you don't have to reinstall between testing
* `--overwrite`: This just overwites files that already exist instead of prompting. This is very usefull when running the script multiple times to test the templates or to code that emits the template.
* `--language cs`: this is one of the public flags to generate a cs project instead of a cpp project.
* `--experimentalNugetDependency`: This is the critical one to let the template emit referneces to NuGet package rather than source pacakges. When we make it the default this will likely be renamed back to source for those that need a tight loop between test projects from template and the product code for developers working 'on' react-native-windows. If it proves that the sample and test apps we have in the repo satisfy this need, it can be removed and the tempaltes can be cleaned up by removing a lot of the conditionals bewteen the two.
* `--nuGetTestFeed c:\temp\RnWNugetTesting\feed`: This flag adds an extra feed to the nuget.config so that for local testing you can use a different feed. This is the default location that is pushed to by the `PublishNugetPackagesLocally.cmd` script.
* `--nuGetTestVersion 0.0.1-MyTest001`: By default the NuGet version matches the react-native version. For testing this can be cumbersome. Therefore this flag allows you to specify the version number for the NuGet packages.

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

@ -55,10 +55,10 @@ const argv = yargs
describe: 'Overwrite any existing files without prompting',
default: false,
},
experimentalNuGetDependency: {
experimentalNugetDependency: {
type: 'boolean',
describe:
'Experimental change to start consuming a NuGet containing a pre-built dll version of Microsoft.ReactNative',
'[Experimental] change to start consuming a NuGet containing a pre-built dll version of Microsoft.ReactNative',
hidden: true,
default: false,
},
@ -68,10 +68,22 @@ const argv = yargs
hidden: true,
default: false,
},
nuGetTestVersion: {
type: 'string',
describe:
'[internalTesting] By default the NuGet version matches the rnw package. This flag allows manually specifying the version for internal testing.',
hidden: true,
},
nuGetTestFeed: {
type: 'string',
describe:
'[internalTesting] Allows a test feed to be added to the generated NuGet configuration',
hidden: true,
},
useDevMode: {
type: 'boolean',
describe:
'Link rather than Add/Install the react-native-windows package. This option is for the development workflow of the developers working on react-native-windows.',
'[internalTesting] Link rather than Add/Install the react-native-windows package. This option is for the development workflow of the developers working on react-native-windows.',
hidden: true,
default: false,
},
@ -317,10 +329,10 @@ function isProjectUsingYarn(cwd: string): boolean {
const useDevMode = argv.useDevMode;
let version = argv.version;
if (argv.useWinUI3 && argv.experimentalNuGetDependency) {
if (argv.useWinUI3 && argv.experimentalNugetDependency) {
// WinUI3 is not yet compatible with NuGet packages
console.error(
"Error: Incompatible options specified. Options '--useWinUI3' and '--experimentalNuGetDependency' are incompatible",
"Error: Incompatible options specified. Options '--useWinUI3' and '--experimentalNugetDependency' are incompatible",
);
process.exit(EXITCODE_INCOMPATIBLE_OPTIONS);
}
@ -418,8 +430,10 @@ You can either downgrade your version of ${chalk.green(
language: argv.language as 'cs' | 'cpp',
overwrite: argv.overwrite,
verbose: argv.verbose,
experimentalNuGetDependency: argv.experimentalNuGetDependency,
experimentalNugetDependency: argv.experimentalNugetDependency,
useWinUI3: argv.useWinUI3,
nuGetTestVersion: argv.nuGetTestVersion,
nuGetTestFeed: argv.nuGetTestFeed,
});
} catch (error) {
console.error(chalk.red(error.message));

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

@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PlatformTarget>x64</PlatformTarget>

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

@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>

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

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="16.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="16.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -17,13 +16,17 @@
<MinimumVisualStudioVersion>16</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<DocumentationFile>bin\$(Platform)\$(Configuration)\Microsoft.ReactNative.Managed.XML</DocumentationFile>
<Deterministic>true</Deterministic>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<NoWarn>;2008</NoWarn>
<NoWarn>$(NoWarn);1591</NoWarn> <!-- Missing XML comment for publicly visible type or member -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
@ -33,7 +36,6 @@
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
@ -43,7 +45,6 @@
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
@ -53,7 +54,6 @@
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
@ -63,7 +63,6 @@
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
@ -73,7 +72,6 @@
<OutputPath>bin\ARM64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
@ -83,7 +81,6 @@
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
@ -93,7 +90,6 @@
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
@ -103,7 +99,7 @@
</PropertyGroup>
<Import Project="..\PropertySheets\WinUI.props" />
<ItemGroup>
<Compile Include="AttributedViewManager.cs" />
<Compile Include="AttributedViewManager.cs" />
<Compile Include="IJSValueTreeReader.cs" />
<Compile Include="IReactPromise.cs" />
<Compile Include="JSValue.cs" />
@ -153,5 +149,5 @@
<VisualStudioVersion>16.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<Target Name="Deploy"/>
<Target Name="Deploy" />
</Project>

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

@ -11,7 +11,7 @@ namespace Microsoft.ReactNative.Managed
/// </summary>
/// <typeparam name="T">This must be thea type defined in the assembly where the items for the react package should be extracted.</typeparam>
/// <remarks>
/// The common use case of this type is adding this to the PackageProviders from the constructor of your application (say: in <c>App()</c> of App.g.cs) like <c>PackageProviders.Add(new ReflectionReactPackageProvider<App>());</c>.
/// The common use case of this type is adding this to the PackageProviders from the constructor of your application (say: in <c>App()</c> of App.g.cs) like <c>PackageProviders.Add(new ReflectionReactPackageProvider&lt;App&gt;());</c>.
/// </remarks>
public class ReflectionReactPackageProvider<T> : IReactPackageProvider
{
@ -31,12 +31,13 @@ namespace Microsoft.ReactNative.Managed
/// </summary>
/// <typeparam name="T">This must be thea type defined in the assembly where the items for the react package should be extracted.</typeparam>
/// <remarks>
/// The common use case of this type is when you have a react library. Then you would call this from the <see cref="IReactPackageBuilder.CreatePackage"/> function in ReactPackageProvider class that implements <see cref="IReactPackageProvider"/> like: <c>
/// The common use case of this type is when you have a react library. Then you would call this from the <see cref="IReactPackageProvider.CreatePackage"/> function in ReactPackageProvider class that implements <see cref="IReactPackageProvider"/> like:
/// <c>
/// public sealed class ReactPackageProvider : IReactPackageProvider
/// {
/// public void CreatePackage(IReactPackageBuilder packageBuilder)
/// {
/// packageBuilder.AddReflectionReactPackageProvider<ReactPackageProvider>();
/// packageBuilder.AddReflectionReactPackageProvider&lt;ReactPackageProvider&gt;();
/// }
/// }
/// </c>.

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

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- To avoid having these references show in in Visual Studio which ignores conditions on items we have to put the source references in source. -->
<ItemGroup>
<ProjectReference Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Microsoft.ReactNative.vcxproj">
<Project>{f7d32bd0-2749-483e-9a0d-1635ef7e3136}</Project>
<Name>Microsoft.ReactNative</Name>
</ProjectReference>
<ProjectReference Include="$(ReactNativeWindowsDir)Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.csproj">
<Project>{F2824844-CE15-4242-9420-308923CD76C3}</Project>
<Name>Microsoft.ReactNative.Managed</Name>
</ProjectReference>
<!-- WinUI package name and version are set by WinUI.props -->
<PackageReference Include="$(WinUIPackageName)" Version="$(WinUIPackageVersion)" />
</ItemGroup>
</Project>

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

@ -32,17 +32,7 @@
ContinueOnError="false" />
</Target>
<ItemGroup>
<ProjectReference Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Microsoft.ReactNative.vcxproj">
<Project>{f7d32bd0-2749-483e-9a0d-1635ef7e3136}</Project>
<Name>Microsoft.ReactNative</Name>
</ProjectReference>
<ProjectReference Include="$(ReactNativeWindowsDir)Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.csproj">
<Project>{F2824844-CE15-4242-9420-308923CD76C3}</Project>
<Name>Microsoft.ReactNative.Managed</Name>
</ProjectReference>
<!-- WinUI package name and version are set by WinUI.props -->
<PackageReference Include="$(WinUIPackageName)" Version="$(WinUIPackageVersion)" />
</ItemGroup>
<!-- Due to visual studio undonditionally showing references, we have to trick it by making it impossible for VS to find the reference differences between building as source and building as NuGet -->
<Import Project="$(ReactNativeWindowsDir)PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.SourceReferences.targets"
Condition="!$(UseExperimentalNuget)" />
</Project>

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

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<description>Contains Windows Implementation of React-Native for Managed code</description>
<authors>Microsoft</authors>
<projectUrl>https://github.com/microsoft/react-native-windows</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<repository type="git"
url="https://github.com/microsoft/react-native-windows.git"
commit="$CommitId$" />
<tags>react react-native native-module microsoft c# csharp</tags>
<dependencies>
<group targetFramework="UAP10.0">
<dependency id="Microsoft.UI.Xaml" version="2.3.191129002" />
<dependency id="Microsoft.NETCore.UniversalWindowsPlatform" version="6.2.9" />
<dependency id="Microsoft.ReactNative" version="$version$" />
</group>
</dependencies>
</metadata>
<files>
<file src="$nugetroot$\$baseplatform$\$baseconfiguration$\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\ref\Microsoft.ReactNative.Managed.dll" target="ref\uap10.0"/>
<file src="$nugetroot$\$baseplatform$\$baseconfiguration$\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.xml" target="ref\uap10.0"/>
<file src="$nugetroot$\ARM\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.dll" target="runtimes\win10-arm\native" />
<file src="$nugetroot$\ARM\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pdb" target="runtimes\win10-arm\native" />
<file src="$nugetroot$\ARM\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pri" target="runtimes\win10-arm\native" />
<file src="$nugetroot$\ARM\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.dll" target="runtimes\win10-arm\native" />
<file src="$nugetroot$\ARM\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pdb" target="runtimes\win10-arm\native" />
<file src="$nugetroot$\ARM\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pri" target="runtimes\win10-arm\native" />
<file src="$nugetroot$\ARM64\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.dll" target="runtimes\win10-arm64\native" />
<file src="$nugetroot$\ARM64\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pdb" target="runtimes\win10-arm64\native" />
<file src="$nugetroot$\ARM64\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pri" target="runtimes\win10-arm64\native" />
<file src="$nugetroot$\ARM64\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.dll" target="runtimes\win10-arm64\native" />
<file src="$nugetroot$\ARM64\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pdb" target="runtimes\win10-arm64\native" />
<file src="$nugetroot$\ARM64\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pri" target="runtimes\win10-arm64\native" />
<file src="$nugetroot$\x86\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.dll" target="runtimes\win10-x86\native" />
<file src="$nugetroot$\x86\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pdb" target="runtimes\win10-x86\native" />
<file src="$nugetroot$\x86\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pri" target="runtimes\win10-x86\native" />
<file src="$nugetroot$\x86\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.dll" target="runtimes\win10-x86\native" />
<file src="$nugetroot$\x86\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pdb" target="runtimes\win10-x86\native" />
<file src="$nugetroot$\x86\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pri" target="runtimes\win10-x86\native" />
<file src="$nugetroot$\x64\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.dll" target="runtimes\win10-x64\native" />
<file src="$nugetroot$\x64\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pdb" target="runtimes\win10-x64\native" />
<file src="$nugetroot$\x64\Release\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pri" target="runtimes\win10-x64\native" />
<file src="$nugetroot$\x64\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.dll" target="runtimes\win10-x64\native" />
<file src="$nugetroot$\x64\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pdb" target="runtimes\win10-x64\native" />
<file src="$nugetroot$\x64\Debug\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.pri" target="runtimes\win10-x64\native" />
</files>
</package>

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

@ -10,6 +10,7 @@
<repository type="git"
url="https://github.com/microsoft/react-native-windows.git"
commit="$CommitId$" />
<tags>react react-native microsoft c c++ cpp c# csharp</tags>
</metadata>
<files>

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

@ -1,16 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Native-Platform Condition="'$(Platform)' == 'Win32'">x86</Native-Platform>
<Native-Platform Condition="'$(Platform)' != 'Win32'">$(Platform)</Native-Platform>
</PropertyGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'UAP'">
<Reference Include="$(MSBuildThisFileDirectory)..\..\lib\uap10.0\Microsoft.ReactNative.winmd">
<Implementation>Microsoft.ReactNative.dll</Implementation>
</Reference>
<ReferenceCopyLocalPaths Condition="$(Configuration) == 'Debug'" Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(Native-Platform)\native\debug\Microsoft.ReactNative.dll" />
<ReferenceCopyLocalPaths Condition="$(Configuration) == 'Debug'" Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(Native-Platform)\native\debug\Microsoft.ReactNative.pri" />
<ReferenceCopyLocalPaths Condition="$(Configuration) != 'Debug'" Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(Native-Platform)\native\release\Microsoft.ReactNative.dll" />
<ReferenceCopyLocalPaths Condition="$(Configuration) != 'Debug'" Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(Native-Platform)\native\release\Microsoft.ReactNative.pri" />
</ItemGroup>
<PropertyGroup>
<Native-Platform Condition="'$(Platform)' == 'Win32'">x86</Native-Platform>
<Native-Platform Condition="'$(Platform)' != 'Win32'">$(Platform)</Native-Platform>
<_rnwDebugFolder>$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(Native-Platform)\native\debug\</_rnwDebugFolder>
<_rnwReleaseFolder>$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(Native-Platform)\native\release\</_rnwReleaseFolder>
</PropertyGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'UAP'">
<Reference Include="$(MSBuildThisFileDirectory)..\..\lib\uap10.0\Microsoft.ReactNative.winmd">
<Implementation>Microsoft.ReactNative.dll</Implementation>
</Reference>
<ReferenceCopyLocalPaths Condition="$(Configuration) == 'Debug' and Exists('$(_rnwDebugFolder)Microsoft.ReactNative.dll')" Include="$(_rnwDebugFolder)Microsoft.ReactNative.dll" />
<ReferenceCopyLocalPaths Condition="$(Configuration) == 'Debug' and Exists('$(_rnwDebugFolder)Microsoft.ReactNative.pri')" Include="$(_rnwDebugFolder)Microsoft.ReactNative.pri" />
<!-- fall back to release bits if debug bits are not in package -->
<ReferenceCopyLocalPaths Condition="$(Configuration) == 'Debug' and !Exists('$(_rnwDebugFolder)Microsoft.ReactNative.dll') and Exists('$(_rnwReleaseFolder)Microsoft.ReactNative.dll')" Include="$(_rnwReleaseFolder)Microsoft.ReactNative.dll" />
<ReferenceCopyLocalPaths Condition="$(Configuration) == 'Debug' and !Exists('$(_rnwDebugFolder)Microsoft.ReactNative.pri') and Exists('$(_rnwReleaseFolder)Microsoft.ReactNative.dll')" Include="$(_rnwReleaseFolder)Microsoft.ReactNative.pri" />
<ReferenceCopyLocalPaths Condition="$(Configuration) != 'Debug' and Exists('$(_rnwReleaseFolder)Microsoft.ReactNative.dll')" Include="$(_rnwReleaseFolder)Microsoft.ReactNative.dll" />
<ReferenceCopyLocalPaths Condition="$(Configuration) != 'Debug' and Exists('$(_rnwReleaseFolder)Microsoft.ReactNative.pri')" Include="$(_rnwReleaseFolder)Microsoft.ReactNative.pri" />
<!-- fall back to debug bits if release bits are not in package -->
<ReferenceCopyLocalPaths Condition="$(Configuration) != 'Debug' and !Exists('$(_rnwReleaseFolder)Microsoft.ReactNative.dll') and Exists('$(_rnwDebugFolder)Microsoft.ReactNative.dll')" Include="$(_rnwDebugFolder)Microsoft.ReactNative.dll" />
<ReferenceCopyLocalPaths Condition="$(Configuration) != 'Debug' and !Exists('$(_rnwReleaseFolder)Microsoft.ReactNative.pri') and Exists('$(_rnwDebugFolder)Microsoft.ReactNative.dll')" Include="$(_rnwDebugFolder)Microsoft.ReactNative.pri" />
</ItemGroup>
</Project>

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

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

@ -0,0 +1,73 @@
@echo off
set version=%1
set targetDir=%2
set slices=%3
set basePlatform=%4
set baseConfiguration=%5
set ScriptFolder=%~dp0
set defaultTargetDir=c:\temp\RnWNugetTesting
set defaultSlices="@('x64.Debug')"
set defaultBaseConfiguration=Debug
set defaultBasePlatform=x64
echo Invoking publish nuget packages with: %0 %*
:PrepVersion
if "%version%" == "" (
echo Usage: %~nx0 ^<version^> [^<targetDir^>] [^<slices^>] [^<basePlatform^>] [^<baseConfiguration^>]
echo.
echo Example: %~nx0 0.0.1-Test001
echo Example: %~nx0 0.0.1-Test001 %defaultTargetDir% %defaultSlices%
echo Example: %~nx0 0.0.1-Test001 %defaultTargetDir% %defaultSlices% %defaultBasePlatform% %defaultBaseConfiguration%
exit /b 1
)
if "%baseConfiguration%" == "" (
set baseConfiguration=%defaultBaseConfiguration%
)
if "%basePlatform%" == "" (
set basePlatform=%defaultBasePlatform%
)
:PrepTargetDir
if "%targetDir%" == "" (
set targetDir=%defaultTargetDir%
)
if EXIST %targetDir% (
rmdir /s/q %targetDir%
)
mkdir %targetDir%\pkgs
mkdir %targetDir%\feed
:PrepSlices
if "%slices%" == "" (
set slices=%defaultSlices%
)
call :ProcessNuget Microsoft.ReactNative
call :ProcessNuget Microsoft.ReactNative.Managed -preferRelease $true
exit /b 0
:ProcessNuget
set packageId=%1
set nuspecFile=%1.nuspec
set targetNuspec=%targetDir%\pkgs\%nuspecFile%
set targetNupkg=%targetDir%\pkgs\%packageId%.%version%.nupkg
set nugetRoot=%ScriptFolder%..\target
if NOT EXIST %nugetRoot%\Microsoft.ReactNative.Cxx (
mkdir %nugetRoot%\Microsoft.ReactNative.Cxx
)
echo.
echo --------------------------------
echo.
echo Processing %packageId%
echo.
echo --------------------------------
powershell %ScriptFolder%StripAdditionalPlatformsFromNuspec.ps1 -nuspec %scriptFolder%%nuspecFile% -outFile %targetNuspec% -slices %slices% %2 %3 %4 %5
echo nuget pack %targetNuspec% -properties CommitId=TestCommit;version=%version%;id=%packageId%;nugetroot=%nugetRoot%;baseconfiguration=%baseConfiguration%;baseplatform=%basePlatform%
nuget pack %targetNuspec% -OutputDirectory %targetDir%\pkgs -properties CommitId=TestCommit;version=%version%;id=%packageId%;nugetroot=%nugetRoot%;baseconfiguration=%baseConfiguration%;baseplatform=%basePlatform%
nuget add %targetNupkg% -Source %targetDir%\feed
goto :EOF

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

@ -1,11 +1,17 @@
# For PR builds we dont want to have to build _ALL_ the platforms just to get a NuGet and test one platform.
# this script filters the files required by the NuGet, so we can produce a test NuGet on a single platform
[CmdletBinding()]
param (
[string]$nuspec = "$PSScriptRoot\Microsoft.ReactNative.nuspec",
[string]$outfile = "$PSScriptRoot\Microsoft.ReactNative.PR.nuspec",
[string[]]$slices = @("x64.Release")
)
[string[]]$slices = @("x64.Release"),
[boolean]$preferRelease = $false
)
# Allow write-debug to work in CI without prompting and breaking there.
If ($PSBoundParameters['Debug']) {
$DebugPreference = 'Continue'
}
Write-Output "Creating filtered version of : $nuspec"
$xml = [xml](gc $nuspec)
@ -22,25 +28,40 @@ foreach($s in $slices) {
}
}
foreach($file in $xml.package.files.ChildNodes) {
$filesSection = $xml.package.files;
foreach($file in $filesSection.ChildNodes) {
if ($file.NodeType -eq "Comment") {
continue;
}
Write-Debug "Testing file: $($file.src)"
foreach($slice in $allSlices) {
$sliceInfo = $slice.split('.');
$platform = $sliceInfo[0];
$flavor = $sliceInfo[1];
if ($file.src.Contains($platform) -and $file.src.Contains($flavor) -and !$slices.Contains("$platform.$flavor")) {
$nodesToRemove += $file
break;
if ($file.src.Contains("\$platform\$flavor\")) {
Write-Debug " Matched to slice: $slice"
if (!$slices.Contains("$platform.$flavor")) {
Write-Debug " remove due to not in slice"
$nodesToRemove += $file
break;
}
if ($preferRelease -and $flavor -eq "Debug" -and $slices.Contains("$platform.Release")) {
Write-Debug " remove because it is debug and there is a release version requested"
# We are checking for the debug version. THere is a release version and we prefer release bits1111
$nodesToRemove += $file
break;
}
}
}
}
foreach ($node in $nodesToRemove) {
Write-Debug $xml.package.files.RemoveChild($node);
Write-Debug "Removing file $($node.src)";
$x = $filesSection.RemoveChild($node);
}
$xml.save($outfile);

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

@ -31,7 +31,9 @@ import {
export interface GenerateOptions {
overwrite: boolean;
language: 'cpp' | 'cs';
experimentalNuGetDependency: boolean;
experimentalNugetDependency: boolean;
nuGetTestVersion?: string;
nuGetTestFeed?: string;
useWinUI3: boolean;
verbose: boolean;
}

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

@ -86,6 +86,24 @@ async function generateCertificate(
return null;
}
/**
* This represents the data to insert nuget packages
*/
interface NugetPackage {
id: string;
version: string;
}
/**
* This represents the data to insert nuget packages with Cpp specific information
*/
interface CppNugetPackage extends NugetPackage {
propsTopOfFile?: boolean;
propsMiddleOfFile?: boolean;
hasProps: boolean;
hasTargets: boolean;
}
export async function copyProjectTemplateAndReplace(
srcRootPath: string,
destPath: string,
@ -112,7 +130,7 @@ export async function copyProjectTemplateAndReplace(
const language = options.language;
const namespaceCpp = toCppNamespace(namespace);
if (options.experimentalNuGetDependency) {
if (options.experimentalNugetDependency) {
console.log('Using experimental NuGet dependency.');
}
if (options.useWinUI3) {
@ -121,8 +139,10 @@ export async function copyProjectTemplateAndReplace(
}
const projDir = 'proj';
const srcPath = path.join(srcRootPath, language);
const sharedPath = path.join(srcRootPath, 'shared');
const projectGuid = uuid.v4();
const rnwVersion = require('react-native-windows/package.json').version;
const nugetVersion = options.nuGetTestVersion || rnwVersion;
const packageGuid = uuid.v4();
const currentUser = username.sync()!; // Gets the current username depending on the platform.
const certificateThumbprint = await generateCertificate(
@ -147,14 +167,14 @@ export async function copyProjectTemplateAndReplace(
throw new Error('Unable to find WinUI3 version from property sheets');
}
const cppNugetPackages: Array<{
id: string;
version: string;
propsTopOfFile?: boolean;
propsMiddleOfFile?: boolean;
hasProps: boolean;
hasTargets: boolean;
}> = [
const csNugetPackages: NugetPackage[] = [
{
id: 'Microsoft.NETCore.UniversalWindowsPlatform',
version: '6.2.9',
},
];
const cppNugetPackages: CppNugetPackage[] = [
{
id: 'Microsoft.Windows.CppWinRT',
version: '2.0.200615.7',
@ -170,10 +190,15 @@ export async function copyProjectTemplateAndReplace(
},
];
if (options.experimentalNuGetDependency) {
if (options.experimentalNugetDependency) {
csNugetPackages.push({
id: 'Microsoft.ReactNative.Managed',
version: nugetVersion,
});
cppNugetPackages.push({
id: 'Microsoft.ReactNative',
version: rnwVersion,
version: nugetVersion,
propsMiddleOfFile: true,
hasProps: false,
hasTargets: true,
@ -199,7 +224,8 @@ export async function copyProjectTemplateAndReplace(
currentUser: currentUser,
certificateThumbprint: certificateThumbprint,
useExperimentalNuget: options.experimentalNuGetDependency,
useExperimentalNuget: options.experimentalNugetDependency,
nuGetTestFeed: options.nuGetTestFeed,
// cpp template variables
useWinUI3: options.useWinUI3,
@ -207,6 +233,9 @@ export async function copyProjectTemplateAndReplace(
xamlNamespaceCpp: xamlNamespaceCpp,
cppNugetPackages: cppNugetPackages,
// cs template variables
csNugetPackages: csNugetPackages,
// autolinking template variables
autolinkProjectReferencesForTargets: '',
autolinkCsUsingNamespaces: '',
@ -297,17 +326,24 @@ export async function copyProjectTemplateAndReplace(
options.overwrite,
);
}
}
// Once we are publishing to nuget.org, this shouldn't be needed anymore
if (options.experimentalNuGetDependency) {
await copyAndReplaceWithChangedCallback(
path.join(srcPath, projDir, 'NuGet.Config'),
// Once we are publishing to nuget.org, this shouldn't be needed anymore
if (options.experimentalNugetDependency) {
[
{
from: path.join(sharedPath, projDir, 'NuGet.Config'),
to: path.join(windowsDir, 'NuGet.Config'),
},
].forEach(mapping =>
copyAndReplaceWithChangedCallback(
mapping.from,
destPath,
path.join(windowsDir, 'NuGet.Config'),
mapping.to,
templateVars,
options.overwrite,
);
}
),
);
}
await copyAndReplaceAll(

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

@ -27,6 +27,9 @@
<PackageCertificatePassword>password</PackageCertificatePassword>
<AppxGeneratePrisForPortableLibrariesEnabled>false</AppxGeneratePrisForPortableLibrariesEnabled>
<LangVersion>7.3</LangVersion>
{{#useExperimentalNuget}}
<UseExperimentalNuget>true</UseExperimentalNuget> <!-- This will eventually default to true and this property should be removed -->
{{/useExperimentalNuget}}
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
@ -160,9 +163,11 @@
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.9</Version>
{{#csNugetPackages}}
<PackageReference Include="{{ id }}">
<Version>{{ version }}</Version>
</PackageReference>
{{/csNugetPackages}}
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '16.0' ">
<VisualStudioVersion>16.0</VisualStudioVersion>
@ -181,15 +186,4 @@
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.props'))" />
<Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CSharpApp.targets'))" />
</Target>
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

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

@ -5,6 +5,7 @@ VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{ name }}", "{{ name }}\{{ name }}.csproj", "{{ projectGuidUpper }}"
EndProject
{{^useExperimentalNuget}}
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Folly", "..\node_modules\react-native-windows\Folly\Folly.vcxproj", "{A990658C-CE31-4BCC-976F-0FC6B1AF693D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReactCommon", "..\node_modules\react-native-windows\ReactCommon\ReactCommon.vcxproj", "{A9D95A91-4DB7-4F72-BEB6-FE8A5C89BFBD}"
@ -34,7 +35,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.ReactNative.Share
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ReactNative.Managed", "..\node_modules\react-native-windows\Microsoft.ReactNative.Managed\Microsoft.ReactNative.Managed.csproj", "{F2824844-CE15-4242-9420-308923CD76C3}"
EndProject
{{/useExperimentalNuget}}
Global
{{^useExperimentalNuget}}
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems*{0cc28589-39e4-4288-b162-97b959f8b843}*SharedItemsImports = 9
..\node_modules\react-native-windows\Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9
@ -47,6 +50,7 @@ Global
..\node_modules\react-native-windows\Mso\Mso.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
..\node_modules\react-native-windows\Shared\Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
EndGlobalSection
{{/useExperimentalNuget}}
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
@ -82,6 +86,7 @@ Global
{{ projectGuidUpper }}.Release|x86.ActiveCfg = Release|x86
{{ projectGuidUpper }}.Release|x86.Build.0 = Release|x86
{{ projectGuidUpper }}.Release|x86.Deploy.0 = Release|x86
{{^useExperimentalNuget}}
{A990658C-CE31-4BCC-976F-0FC6B1AF693D}.Debug|ARM.ActiveCfg = Debug|ARM
{A990658C-CE31-4BCC-976F-0FC6B1AF693D}.Debug|ARM.Build.0 = Debug|ARM
{A990658C-CE31-4BCC-976F-0FC6B1AF693D}.Debug|ARM64.ActiveCfg = Debug|ARM64
@ -178,10 +183,12 @@ Global
{F2824844-CE15-4242-9420-308923CD76C3}.Release|x64.Build.0 = Release|x64
{F2824844-CE15-4242-9420-308923CD76C3}.Release|x86.ActiveCfg = Release|x86
{F2824844-CE15-4242-9420-308923CD76C3}.Release|x86.Build.0 = Release|x86
{{/useExperimentalNuget}}
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
{{^useExperimentalNuget}}
GlobalSection(NestedProjects) = preSolution
{A990658C-CE31-4BCC-976F-0FC6B1AF693D} = {5EA20F54-880A-49F3-99FA-4B3FE54E8AB1}
{A9D95A91-4DB7-4F72-BEB6-FE8A5C89BFBD} = {5EA20F54-880A-49F3-99FA-4B3FE54E8AB1}
@ -194,6 +201,7 @@ Global
{2049DBE9-8D13-42C9-AE4B-413AE38FFFD0} = {5EA20F54-880A-49F3-99FA-4B3FE54E8AB1}
{F2824844-CE15-4242-9420-308923CD76C3} = {5EA20F54-880A-49F3-99FA-4B3FE54E8AB1}
EndGlobalSection
{{/useExperimentalNuget}}
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D43FAD39-F619-437D-BB40-04A3982ACB6A}
EndGlobalSection

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

@ -4,7 +4,10 @@
<add key="repositoryPath" value="packages" />
</config>
<packageSources>
{{#nuGetTestFeed}}
<add key="NuGetTestFeed" value="{{ nuGetTestFeed }}" />
{{/nuGetTestFeed}}
<add key="Nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="react-native" value="https://pkgs.dev.azure.com/ms/_packaging/react-native/nuget/v3/index.json" />
<add key="react-native" value="https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/nuget/v3/index.json" />
</packageSources>
</configuration>