Unresolved reference to symbol 'Directory:Component_A.Binaries' in section 'Fragment:' - wix3.11

I have two simple console app projects "Component-A" and "Component-B" which I want to include in my SetupWixDemo project in my solution.
In my Wix project file for Setup I have enabled Harvesting project
<PropertyGroup>
<EnableProjectHarvesting>True</EnableProjectHarvesting>
</PropertyGroup>
and included the two projects using HeatProject
<ItemGroup>
<HeatProject Include="..\Component-A\Component-A.csproj">
<ProjectOutputGroups>Binaries</ProjectOutputGroups>
<Link>Component-A.csproj</Link>
</HeatProject>
<HeatProject Include="..\Component-B\Component-B.csproj">
<ProjectOutputGroups>Binaries</ProjectOutputGroups>
<Link>Component-B.csproj</Link>
</HeatProject>
</ItemGroup>
It has generated the components wix files correctly
Generated _Component_A.wxs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Component_A.Binaries">
<Component Id="cmpC008F1473856A259012D9243F2FAA367" Guid="*">
<File Id="fil76224611BE6FE33E8C4C1CB922BE4507" Source="$(var.Component-A.TargetDir)\Component-A.exe" />
</Component>
<Component Id="cmp8F2527F5846E0A97DD990421A1BFE039" Guid="*">
<File Id="fil2887E426D398DC77AF53475EC6CC8E82" Source="$(var.Component-A.TargetDir)\Component-A.exe.config" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="Component_A.Binaries">
<ComponentRef Id="cmpC008F1473856A259012D9243F2FAA367" />
<ComponentRef Id="cmp8F2527F5846E0A97DD990421A1BFE039" />
</ComponentGroup>
</Fragment>
</Wix>
Generated _Component_B.wxs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Component_B.Binaries">
<Component Id="cmpC4EEFA1957E631623A020D230FE7FE27" Guid="*">
<File Id="fil027682CC235FE3E8DB7E93B17A690B4E" Source="$(var.Component-B.TargetDir)\Component-B.exe" />
</Component>
<Component Id="cmp5DCF4C7D83433EA092BBF18737C93FB1" Guid="*">
<File Id="filA4BD1B738072866436267073D1E70237" Source="$(var.Component-B.TargetDir)\Component-B.exe.config" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="Component_B.Binaries">
<ComponentRef Id="cmpC4EEFA1957E631623A020D230FE7FE27" />
<ComponentRef Id="cmp5DCF4C7D83433EA092BBF18737C93FB1" />
</ComponentGroup>
</Fragment>
</Wix>
Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupWixDemo" Language="1033" Version="1.0.0.0" Manufacturer="WK" UpgradeCode="60e5ca62-51b5-47d3-81b5-a36b078c88c5">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of SetupWixDemo is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupWixDemo" Level="1">
<ComponentGroupRef Id="Component_A.Binaries" />
<ComponentGroupRef Id="Component_B.Binaries" />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" />
</Product>
<Fragment>
<SetDirectory Id="INSTALLFOLDER" Value="[WindowsVolume]Apps\WixDemo" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="SetupWixDemo" />
</Directory>
</Directory>
</Fragment>
</Wix>
I keep getting the following.
Unresolved reference to symbol 'Directory:Component_A.Binaries' in section 'Fragment:'
Unresolved reference to symbol 'Directory:Component_B.Binaries' in section 'Fragment:'
What am I doing wrong ?
UPDATE:
Found a fix for this error . Realized I need to include both the Directory entry for both components
<Fragment>
<SetDirectory Id="INSTALLFOLDER" Value="[WindowsVolume]Apps\WixDemo" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="WixDemo" />
<Directory Id="Component_A.Binaries" Name="WixDemo" />
<Directory Id="Component_B.Binaries" Name="WixDemo" />
</Directory>
</Directory>
</Fragment>
Though now its not installing anything and no errors.

Found the remaining issue. It was installing under program files. So had to include SetDirectory tag for each component and that fixed it.
<Fragment>
<SetDirectory Id="INSTALLFOLDER" Value="[WindowsVolume]Apps\WixDemo" />
<SetDirectory Id="Component_A.Binaries" Value="[WindowsVolume]Apps\WixDemo" />
<SetDirectory Id="Component_B.Binaries" Value="[WindowsVolume]Apps\WixDemo" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="WixDemo" />
<Directory Id="Component_A.Binaries" Name="WixDemo" />
<Directory Id="Component_B.Binaries" Name="WixDemo" />
</Directory>
</Directory>
</Fragment>

Related

How to set up React on IIS without rewrite rules nor Hashrouter

When I deploy the React App to IIS Web Server, the pages 404. I know I can fix this issue with a rewrite rule or hash router. Is there any other way?
The set up in app.js
<Switch>
<Route exact path="/Documents/Home" component={Home} />
<Route exact path="/Documents" component={Documents} />
<Route component={NotFoundPage} />
</Switch>
You can set up a rewrite rule in the web.config to have IIS point to index.html
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReactRouter Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Or I can wrap the routes in a HashRouter so it doesn't send the route info to the web server. though it has a /#/ in the url.
<HashRouter>
<Switch>
<Route exact path="/Documents/Home" component={Home} />
<Route exact path="/Documents" component={Documents} />
<Route component={NotFoundPage} />
</Switch>
</HashRouter>
Is there a third way of fixing this issue of routing on IIS?

How to deploy a multi-page react application in IIS server?

I have created a multipage application using reactjs and have manage the routing using react router-dom. I tested it using npm start and it is working fine. The pages are properly redirecting. But when I run "npm run build" and add it to IIs server, only the home page is coming. No matter what link I click on, I am getting redirected to the home page.
I tried modifying the web.config file.
`
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
`
But it seems the index.html is not updated with the rest of the pages other than the homepage. My user routes are `
<BrowserRouter>
<Routes>
<Route exact path="/" element={<HomepageAtm />} />
<Route
exact
path="/New-Registration"
element={<RegistrationAtm />}
/>
<Route exact path="/View" element={<VIEW_ATM />} />
<Route exact path="/List_View" element={<LIST_VIEW />} />
<Route exact path="/Airport_View" element={<AIRPORT_VIEW />} />
<Route exact path="/Map_View" element={<MAP_VIEW />} />
<Route exact path="/History_Data" element={<History_Data />} />
<Route exact path="/ContactUs" element={<Contact />} />
<Route exact path="/Terminalarea_View" element={<TERMINALAREA_VIEW />} />
</Routes>
</BrowserRouter>
`
I also tried using HashRouter but the results were same. Except for the home page, no other pages are loading.

IIS proxy reverse

Pay attention to the following examples.
subdomain1.sample.com => target.sample.com/1001
subdomain1.sample.com/order => target.sample.com/1001/order
subdomain1.sample.com/login => target.sample.com/1001/login
subdomain2.sample.com => target.sample.com/1002
subdomain2.sample.com/order => target.sample.com/1002/order
subdomain2.sample.com/login => target.sample.com/1002/login
A reactjs project is running on target.sample.com, which is as follows
/ ==>‌ page not found
/:id ==> home
/:id/login ==> page login
/:id/order ==> page order
We want to do this in IIS with the help of proxy reverse or rewrite.
Below are the settings of the web.config file related to the subdomain1.sample.com address
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="http_to_https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
</rule>
<rule name="proxy" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="https://target.sample.com/1001/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^https://target.sample.com/1001/(.*)" />
<action type="Rewrite" value="https://subdomain1.sample.com/{R:1}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="https://{HTTP_HOST}{REQUEST_URI}" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
such an error can be seen in the browser console
Uncaught SyntaxError: Unexpected token '<' (at main.697bcedd.js:1:1)
Have I gone the wrong way? How can I solve this problem?

How to serve a static html file with react app in iframe when using react router?

I'm currently having problems when serving a HTML file in my react app. I use #nrwl/react to build my application.
The html folder is present after building my application (in the public folder).
My setup works when running the application locally. The moment I deploy the application and host it I think the react router is messing up the path. In the deployed version I see my application nested with a blank screen in my iframe.
Router:
<Switch>
<Route path="/" exact />
<Route path="/home" component={HomeComp} />
<Route path="/iframe" component={IframeComp} />
<Route onEnter={() => window.location.reload()} />
<Route component={NotFoundPage} />
</Switch>
IframeComp:
import React from 'react';
const IframeComp= () => {
return (
<iframe
src="/staticfolder/index.html"
></iframe>
);
};
export default IframeComp;
My rewrite rules in web.config
<rewrite>
<rules>
<rule name="HTTPSs">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="Off"/>
<add input="{HTTP_HOST}" negate="true" pattern="^localhost" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
</rule>
<rule name="ReactRoutes" stopProcessing="true">
<match url="^(?!api|swagger).*" />
<conditions>
<add input="{HTTP_METHOD}" pattern="^GET$" />
<add input="{HTTP_ACCEPT}" pattern="^text/html" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>

React app deployed to IIS StaticFile handler problem

I have a sample React application. I deployed the application to IIS. Default page is OK, but /category page returns 404 - File or directory not found.
import { Route, BrowserRouter } from "react-router-dom";
const Home = () => (
<div>
<h2>Home</h2>
</div>
);
const Category = () => (
<div>
<h2>Category</h2>
</div>
);
export default function App() {
return (
<BrowserRouter>
<Route path="/"><Home /></Route>
<Route path="/category"><Category /></Route>
</BrowserRouter>
);
}
Web.config file content. runAllManagedModulesForAllRequests solution not working unfortunately.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
</modules>
</system.webServer>
</configuration>
Detailed Error Information
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code 0x80070002
ny suggestion please
Using URL rewrite modul, redirect all requests to index.html file.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Resources