Skip to content

Commit

Permalink
Deploy from layout (microsoft#4945)
Browse files Browse the repository at this point in the history
* deploy from layout
  • Loading branch information
asklar committed May 20, 2020
1 parent 09a610e commit b3fc68f
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 15 deletions.
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "deploy from layout",
"packageName": "react-native-windows",
"email": "asklar@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-05-18T23:45:52.436Z"
}
1 change: 1 addition & 0 deletions vnext/Common/Common.vcxproj
Expand Up @@ -111,4 +111,5 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Target Name="Deploy" />
</Project>
1 change: 1 addition & 0 deletions vnext/Folly/Folly.vcxproj
Expand Up @@ -295,6 +295,7 @@
<ItemGroup>
<TemporaryFollyPatchFiles Include="$(MSBuildThisFileDirectory)\TEMP_UntilFollyUpdate\**\*.*" />
</ItemGroup>
<Target Name="Deploy" />
<!-- Reenable this task if we need to temporarily replace any folly files for fixes, while we wait for PRs to land in folly -->
<!--
<Target Name="ApplyFollyTemporaryPatch" BeforeTargets="PrepareForBuild" DependsOnTargets="UnzipFolly">
Expand Down
1 change: 1 addition & 0 deletions vnext/JSI/Universal/JSI.Universal.vcxproj
Expand Up @@ -118,4 +118,5 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Target Name="Deploy" />
</Project>
1 change: 1 addition & 0 deletions vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj
Expand Up @@ -669,4 +669,5 @@
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
</ItemGroup>
</Target>
<Target Name="Deploy" />
</Project>
Expand Up @@ -19,4 +19,18 @@
</ItemGroup>
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Bundle.targets" />
<Import Project="$(ProjectDir)\AutolinkedNativeModules.g.targets" Condition="Exists('$(ProjectDir)\AutolinkedNativeModules.g.targets')" />

<Import Project="$(MSBuildProjectDirectory)\$(OutputPath)\$(AssemblyName).Build.appxrecipe"
Condition="Exists('$(MSBuildProjectDirectory)\$(OutputPath)\$(AssemblyName).Build.appxrecipe')" />
<Target Name="Deploy">
<Error Condition="!Exists('$(MSBuildProjectDirectory)\$(OutputPath)\$(AssemblyName).Build.appxrecipe')"
Text="You must first build the project before deploying it" />
<Copy SourceFiles="%(AppxPackagedFile.Identity)"
DestinationFiles="$(MSBuildProjectDirectory)\$(OutputPath)Appx\%(AppxPackagedFile.PackagePath)" />
<Copy SourceFiles="%(AppXManifest.Identity)"
DestinationFiles="$(MSBuildProjectDirectory)\$(OutputPath)Appx\%(AppxManifest.PackagePath)"
Condition="'%(AppxManifest.SubType)'!='Designer'"/>
<Exec Command="powershell -NonInteractive -NoProfile -Command Add-AppxPackage -Register $(MSBuildProjectDirectory)\$(OutputPath)Appx\AppxManifest.xml"
ContinueOnError="false" />
</Target>
</Project>
Expand Up @@ -14,4 +14,19 @@
</ItemGroup>
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Bundle.Cpp.targets"/>
<Import Project="$(ProjectDir)\AutolinkedNativeModules.g.targets" Condition="Exists('$(ProjectDir)\AutolinkedNativeModules.g.targets')" />

<Import Project="$(OutputPath)\$(AssemblyName).Build.appxrecipe"
Condition="Exists('$(OutputPath)\$(AssemblyName).Build.appxrecipe')" />
<Target Name="Deploy">
<Message Text="OutputPath=$(OutputPath)" />
<Error Condition="!Exists('$(OutputPath)\$(AssemblyName).Build.appxrecipe')"
Text="You must first build the project before deploying it" />
<Copy SourceFiles="%(AppxPackagedFile.Identity)"
DestinationFiles="$(OutputPath)Appx\%(AppxPackagedFile.PackagePath)" />
<Copy SourceFiles="%(AppXManifest.Identity)"
DestinationFiles="$(OutputPath)Appx\%(AppxManifest.PackagePath)"
Condition="'%(AppxManifest.SubType)'!='Designer'"/>
<Exec Command="powershell -NonInteractive -NoProfile -Command Add-AppxPackage -Register $(OutputPath)Appx\AppxManifest.xml"
ContinueOnError="false" />
</Target>
</Project>
1 change: 1 addition & 0 deletions vnext/ReactCommon/ReactCommon.vcxproj
Expand Up @@ -203,4 +203,5 @@
<Error Condition="!Exists('$(ReactNativePackageDir)')" Text="This project references code in the node_modules folder that is missing on this computer. Use `yarn install` to download them." />
<Error Condition="!Exists('$(YogaDir)')" Text="This project references code in the node_modules folder that is missing on this computer. Use `yarn install` to download them." />
</Target>
<Target Name="Deploy" />
</Project>
1 change: 1 addition & 0 deletions vnext/ReactWindowsCore/ReactWindowsCore.vcxproj
Expand Up @@ -4,4 +4,5 @@
<ProjectGuid>{11C084A3-A57C-4296-A679-CAC17B603144}</ProjectGuid>
</PropertyGroup>
<Import Project="ReactWindowsCore.vcxitems" Label="Shared" />
<Target Name="Deploy" />
</Project>
1 change: 1 addition & 0 deletions vnext/local-cli/runWindows/runWindows.js
Expand Up @@ -79,6 +79,7 @@ async function runWindows(config, args, options) {
options.arch,
msBuildProps,
verbose,
undefined, // build the default target
);
} catch (e) {
newError(
Expand Down
2 changes: 2 additions & 0 deletions vnext/local-cli/runWindows/utils/build.js
Expand Up @@ -24,6 +24,7 @@ async function buildSolution(
buildArch,
msBuildProps,
verbose,
target,
) {
const minVersion = new Version(10, 0, 18362, 0);
const allVersions = MSBuildTools.getAllAvailableUAPVersions();
Expand All @@ -40,6 +41,7 @@ async function buildSolution(
buildArch,
msBuildProps,
verbose,
target,
);
}

Expand Down
23 changes: 9 additions & 14 deletions vnext/local-cli/runWindows/utils/deploy.js
Expand Up @@ -22,6 +22,7 @@ const {
commandWithProgress,
runPowerShellScriptFunction,
} = require('./commandWithProgress');
const build = require('./build');

function pushd(pathArg) {
const cwd = process.cwd();
Expand Down Expand Up @@ -167,12 +168,6 @@ async function deployToDevice(options, verbose) {
}
}

async function hasDotNetProjects(slnFile) {
const contents = (await fs.promises.readFile(slnFile)).toString();
let r = /\"([^"]+\.(csproj|vbproj))\"/;
return r.test(contents);
}

async function deployToDesktop(options, verbose, slnFile) {
const appPackageFolder = getAppPackage(options);
const windowsStoreAppUtils = getWindowsStoreAppUtils(options);
Expand Down Expand Up @@ -214,21 +209,21 @@ async function deployToDesktop(options, verbose, slnFile) {
verbose,
);

// #4749 - need to deploy from appx for .net projects.
if (options.release || (await hasDotNetProjects(slnFile))) {
if (options.release) {
await runPowerShellScriptFunction(
'Installing new version of the app',
windowsStoreAppUtils,
`Install-App "${script}" -Force`,
verbose,
);
} else {
const realAppxManifestPath = fs.realpathSync(appxManifestPath);
await runPowerShellScriptFunction(
'Installing new version of the app from layout',
windowsStoreAppUtils,
`Install-AppFromDirectory "${realAppxManifestPath}"`,
verbose,
await build.buildSolution(
slnFile,
options.release ? 'Release' : 'Debug',
options.arch,
null,
options.verbose,
'Deploy',
);
}

Expand Down
13 changes: 12 additions & 1 deletion vnext/local-cli/runWindows/utils/msbuildtools.js
Expand Up @@ -46,7 +46,14 @@ class MSBuildTools {
results.forEach(result => console.log(chalk.white(result)));
}

async buildProject(slnFile, buildType, buildArch, msBuildProps, verbose) {
async buildProject(
slnFile,
buildType,
buildArch,
msBuildProps,
verbose,
target,
) {
newSuccess(`Found Solution: ${slnFile}`);
newInfo(`Build configuration: ${buildType}`);
newInfo(`Build platform: ${buildArch}`);
Expand All @@ -64,6 +71,10 @@ class MSBuildTools {
`/flp1:errorsonly;logfile=${errorLog}`,
];

if (target) {
args.push(`/t:${target}`);
}

if (msBuildProps) {
Object.keys(msBuildProps).forEach(function(key) {
args.push(`/p:${key}=${msBuildProps[key]}`);
Expand Down

0 comments on commit b3fc68f

Please sign in to comment.