pbi-tools / pbi-tools

Power BI DevOps & Source Control Tool
https://pbi.tools/cli
MIT License
299 stars 52 forks source link

An unhandled exception occurred. System.Exception: Process has terminated #78

Closed janmechtel closed 2 years ago

janmechtel commented 2 years ago

First of, we are ecstatic to see this released! Unfortunately I can't get it to run. I hope it's fine to post here.

I'm trying to start out by extracting from a .pbix fiel

.\pbi-tools.exe extract ".\test.pbix"

An unhandled exception occurred. System.Exception: Process has terminated

An unhandled exception occurred.
System.Exception: Process has terminated
   at PbiTools.PowerBI.AnalysisServicesServer.Start() in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\PowerBI\AnalysisServicesServer.cs:line 145
   at PbiTools.PowerBI.DataModelConverter.LaunchTabularServerAndExecuteCallback[T](Func`2 callback) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\PowerBI\DataModelConverter.cs:line 82
   at PbiTools.Model.PbixModel.FromReader(PbixReader reader, String targetFolder, Nullable`1 portNumber) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Model\PbixModel.cs:line 168
   at PbiTools.Cli.CmdLineActions.Extract(String pbixPath, Int32 pbiPort, String extractFolder, ExtractActionCompatibilityMode mode, ModelSerializationMode modelSerialization, MashupSerializationMode mashupSerialization) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Cli\Extract.cs:line 63
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at PowerArgs.ArgAction.Invoke()
   at PbiTools.Program.Main(String[] args) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Program.cs:line 82
PS C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8> .\pbi-tools.exe extract ".\test.pbix"

I've set the loglevel to verbose, but didn't spot anything more useful.

image

janmechtel commented 2 years ago

Here is the complete vebose log.

PS C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8> .\pbi-tools.exe extract ".\test.pbix"
Log level: Verbose
Invoking 'BeforeValidateDefinition'
Action: Void Cache(PbiTools.Cli.CacheAction)
 Default Alias: Cache
 Alias: Cache
 Alias: cache
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: cache
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
Action: Void CompilePbix(System.String, System.String, PbiTools.PowerBI.PbiFileFormat, Boolean)
 Default Alias: CompilePbix
 Alias: CompilePbix
 Alias: compile
 Alias: compile-pbix
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: compile
 Shortcut: compile-pbix
 Metadata: PowerArgs.ArgDescription
Action: Void Convert(System.String, System.String, PbiTools.ProjectSystem.ModelSerializationMode, PbiTools.ProjectSystem.MashupSerializationMode, System.String, Boolean, Boolean, Boolean)
 Default Alias: Convert
 Alias: Convert
 Alias: convert
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: convert
 Metadata: PowerArgs.ArgDescription
Action: Void Deploy(System.String, System.String, System.String, System.String, Boolean)
 Default Alias: Deploy
 Alias: Deploy
 Alias: deploy
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: deploy
 Metadata: PowerArgs.ArgDescription
Action: Void ExportData(Int32, System.String, System.String, System.String)
 Default Alias: ExportData
 Alias: ExportData
 Alias: export-data
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: export-data
 Metadata: PbiTools.Cli.ArgAltShortcut
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
 Metadata: PowerArgs.ArgExample
Action: Void ExportUsage(System.String)
 Default Alias: ExportUsage
 Alias: ExportUsage
 Alias: export-usage
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: export-usage
 Metadata: PowerArgs.OmitFromUsageDocs
Action: Void Extract(System.String, Int32, System.String, PbiTools.Cli.ExtractActionCompatibilityMode, PbiTools.ProjectSystem.ModelSerializationMode, PbiTools.ProjectSystem.MashupSerializationMode)
 Default Alias: Extract
 Alias: Extract
 Alias: extract
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: extract
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
 Metadata: PowerArgs.ArgExample
Action: Void GenerateBim(System.String, Boolean, PbiTools.Cli.ExportTransforms)
 Default Alias: GenerateBim
 Alias: GenerateBim
 Alias: generate-bim
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: generate-bim
 Metadata: PbiTools.Cli.ArgAltShortcut
 Metadata: PowerArgs.ArgDescription
Action: Void Git(PbiTools.Cli.GitAction)
 Default Alias: Git
 Alias: Git
 Alias: git
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: git
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
Action: Void Info(Boolean)
 Default Alias: Info
 Alias: Info
 Alias: info
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: info
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
Action: Void Init(PbiTools.Cli.InitAction, System.String)
 Default Alias: Init
 Alias: Init
 Alias: init
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: init
 Metadata: PowerArgs.ArgDescription
Action: Void LaunchPbiDesktop(System.String)
 Default Alias: LaunchPbiDesktop
 Alias: LaunchPbiDesktop
 Alias: launch-pbi
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: launch-pbi
 Metadata: PowerArgs.ArgDescription
'RemoveAutoAliases' invoked. Caller: BeforeValidateDefinition
Invoking Action: extract(Aliases=1)(Arguments=6)
Attempting to resolve assembly: Microsoft.PowerBI.Packaging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Using Power BI Desktop install: 2.100.1401.0 (21.12) at C:\Program Files\WindowsApps\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\bin
Assembly 'Microsoft.PowerBI.Packaging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' found at C:\Program Files\WindowsApps\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\bin\Microsoft.PowerBI.Packaging.dll
Reading PbixModel from file at C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\test.pbix (Version: 1.25)
Reading Connections...
Reading Report...
Reading DiagramLayout...
Reading DiagramViewState...
Reading LinguisticSchemaXml...
Reading LinguisticSchema...
Reading ReportMetadata...
Reading ReportSettings...
Reading CustomVisuals...
Reading StaticResources...
Reading DataModel...
MSMDSRV.EXE found at C:\Users\JanMechtel\AppData\Local\pbi-tools\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\msmdsrv.exe
Working directory: C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp
<ConfigurationSettings>
  <TMCompatibilitySKU>0</TMCompatibilitySKU>
  <RecoveryModel>1</RecoveryModel>
  <DisklessModeRequested>1</DisklessModeRequested>
  <InstanceVisible>0</InstanceVisible>
  <AllowedBrowsingFolders>C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp</AllowedBrowsingFolders>
  <Language>8192</Language>
  <Port>0</Port>
  <PrivateProcess>31556</PrivateProcess>
  <BackupDir>C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp</BackupDir>
  <LogDir>C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp</LogDir>
  <TempDir>C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp</TempDir>
  <DataDir>C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp</DataDir>
  <DeploymentMode>1</DeploymentMode>
  <CleanDataFolderOnStartup>1</CleanDataFolderOnStartup>
  <AutoSetDefaultInitialCatalog>1</AutoSetDefaultInitialCatalog>
  <Network>
    <ListenOnlyOnLocalConnections>1</ListenOnlyOnLocalConnections>
    <Requests>
      <EnableBinaryXML>1</EnableBinaryXML>
      <EnableCompression>1</EnableCompression>
    </Requests>
    <Responses>
      <EnableBinaryXML>1</EnableBinaryXML>
      <EnableCompression>1</EnableCompression>
      <CompressionLevel>9</CompressionLevel>
    </Responses>
  </Network>
  <Debug>
    <CallStackInError>0</CallStackInError>
  </Debug>
  <Log>
    <Exception>
      <CrashReportsFolder>C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp</CrashReportsFolder>
    </Exception>
    <Trace>
      <TraceFileBufferSize>128</TraceFileBufferSize>
    </Trace>
    <FlightRecorder>
      <Enabled>1</Enabled>
      <FileSizeMB>50</FileSizeMB>
      <LogDurationSec>36000</LogDurationSec>
    </FlightRecorder>
  </Log>
  <Memory>
    <MemoryHeapType>5</MemoryHeapType>
  </Memory>
  <ResourceGovernance>
    <GovernIMBIScheduler>0</GovernIMBIScheduler>
  </ResourceGovernance>
  <Feature>
    <ManagedCodeEnabled>1</ManagedCodeEnabled>
    <MEngineTracingEnabled>0</MEngineTracingEnabled>
    <UseXPress9Compression>1</UseXPress9Compression>
    <SkipXPress9CompressionSizeMB>0</SkipXPress9CompressionSizeMB>
    <CompositeModel>1</CompositeModel>
    <ManyToManyRelationship>1</ManyToManyRelationship>
    <EnableIncrementalRefresh>1</EnableIncrementalRefresh>
    <ASQLAggEnabled>0</ASQLAggEnabled>
    <ASQLAggRLSEnabled>0</ASQLAggRLSEnabled>
    <WholesaleDax>0</WholesaleDax>
    <DataSourceReferenceEnabled>2</DataSourceReferenceEnabled>
    <EnableMDQV3>1</EnableMDQV3>
  </Feature>
  <VertiPaq>
    <EnableDisklessTMImageSave>1</EnableDisklessTMImageSave>
    <EnableProcessingSimplifiedLocks>1</EnableProcessingSimplifiedLocks>
    <ImageLoadStreamBufferMB>2147483647</ImageLoadStreamBufferMB>
  </VertiPaq>
  <DAX>
    <EnableVariationNotation>1</EnableVariationNotation>
    <DQ>
      <EnableAllFunctions>1</EnableAllFunctions>
      <SelectCartridgeUsingConnectionString>0</SelectCartridgeUsingConnectionString>
    </DQ>
  </DAX>
</ConfigurationSettings>
Started MSMDSRV, PID: 29412
MSMDSRV ERR: null
MSMDSRV INF: null
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp\msmdsrv.bak
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp\msmdsrv.ini
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmpF1FD.tmp\msmdsrv_Failed_ini.bak
An unhandled exception occurred.
System.Exception: Process has terminated
   at PbiTools.PowerBI.AnalysisServicesServer.Start() in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\PowerBI\AnalysisServicesServer.cs:line 145
   at PbiTools.PowerBI.DataModelConverter.LaunchTabularServerAndExecuteCallback[T](Func`2 callback) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\PowerBI\DataModelConverter.cs:line 82
   at PbiTools.Model.PbixModel.FromReader(PbixReader reader, String targetFolder, Nullable`1 portNumber) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Model\PbixModel.cs:line 168
   at PbiTools.Cli.CmdLineActions.Extract(String pbixPath, Int32 pbiPort, String extractFolder, ExtractActionCompatibilityMode mode, ModelSerializationMode modelSerialization, MashupSerializationMode mashupSerialization) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Cli\Extract.cs:line 63
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at PowerArgs.ArgAction.Invoke()
   at PbiTools.Program.Main(String[] args) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Program.cs:line 82
mthierba commented 2 years ago

Hi @janmechtel I wonder whether this might be related to #60.

The extract command, if you are using Power BI Desktop from the MS Store (instead of the MSI version), relies on copying some of the PBI binaries into a temp location within your user profile and running those from there. Some organizations will have restrictions in place prohibiting those files to be executed inside the user profile. The Beta.8 release provided a solution for that: A custom environment variable PBITOOLS_AppDataDir can be set to enable an alternative TEMP dir - one without such restrictions. #60 was resolved that way.

janmechtel commented 2 years ago

Thanks for the super-fast reply.

I do indeed run the store version. I guess I can switch to trying to install the .msi

Setting PBITOOLS_AppDataDir did seem to have an effect as the log shows way more files being copied.

PS C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8> $Env:PBITOOLS_AppDataDir="C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir"
PS C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8> .\pbi-tools.exe extract ".\test.pbix"

Unfortunately the end result is still the same

...
File copied: C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\zh-HANT\Microsoft.Mashup.OAuth.Resources.dll
File copied: C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\zh-HANT\Microsoft.Mashup.OleDbProvider.Resources.dll
File copied: C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\zh-HANT\Microsoft.MashupEngine.Library45.Resources.dll
File copied: C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\zh-HANT\Microsoft.MashupEngine.Resources.dll
File copied: C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\Microsoft.Spatial.NetFX35.dll
File copied: C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\Microsoft.Spatial.NetFX35.V7.dll
File copied: C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\PowerBIExtensions.dll
Using msmdsrv from shadow-copied location: C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8\AppDataDir\Microsoft.MicrosoftPowerBIDesktop_2.100.1401.0_x64__8wekyb3d8bbwe\msmdsrv.exe
Started MSMDSRV, PID: 31468
MSMDSRV INF: null
MSMDSRV ERR: null
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmp26.tmp\msmdsrv.bak
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmp26.tmp\msmdsrv.ini
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmp26.tmp\msmdsrv_Failed_ini.bak
An unhandled exception occurred.
System.Exception: Process has terminated
   at PbiTools.PowerBI.AnalysisServicesServer.Start() in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\PowerBI\AnalysisServicesServer.cs:line 145
   at PbiTools.PowerBI.DataModelConverter.LaunchTabularServerAndExecuteCallback[T](Func`2 callback) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\PowerBI\DataModelConverter.cs:line 82
   at PbiTools.Model.PbixModel.FromReader(PbixReader reader, String targetFolder, Nullable`1 portNumber) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Model\PbixModel.cs:line 168
   at PbiTools.Cli.CmdLineActions.Extract(String pbixPath, Int32 pbiPort, String extractFolder, ExtractActionCompatibilityMode mode, ModelSerializationMode modelSerialization, MashupSerializationMode mashupSerialization) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Cli\Extract.cs:line 63
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at PowerArgs.ArgAction.Invoke()
   at PbiTools.Program.Main(String[] args) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Program.cs:line 82
PS C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8> 
janmechtel commented 2 years ago

I'll try the non-store version of Power BI Desktop

mthierba commented 2 years ago

Okay, thanks for checking that anyway! It's a first - I've extracted thousands of files using this method so far. I wonder whether something is unique to your test PBIX? Have you tried this with others? Would you possibly be able to share a failing file for further diagnostics?

mthierba commented 2 years ago

Actually strike that, I've had another look at your log. Two things here:

Given what I can see, it's very likely this is the same as #60. Please retry with another temp dir.

janmechtel commented 2 years ago

Ok I've installed Power BI Desktop (non-store) and also tried in an Administrator elevated shell. Same problem.

For the test.pbix please see test.zip. It's actually I've created specifically to rule out that it's related to my models.

Maybe it's related to the Working directory: C:\Users\JanMechtel\AppData\Local\Temp\tmp4E5E.tmp I tried to find how to change that?

janmechtel commented 2 years ago

Moved it to C:\Projects still same problem. I'll have a look at the code and see if I can run the MSMDSRV myself?

Maybe there is a way to get a log from it.

PS C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8> $Env:PBITOOLS_LogLevel="Verbose"
PS C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8> $Env:PBITOOLS_AppDataDir="C:\Projects\pbitools\AppData\"
PS C:\Users\JanMechtel\Downloads\pbi-tools.1.0.0-beta.8> pro
PS C:\Projects> cd .\pbitools\
PS C:\Projects\pbitools> .\pbi-tools.exe extract ".\test.pbix"
Log level: Verbose
Invoking 'BeforeValidateDefinition'
Action: Void Cache(PbiTools.Cli.CacheAction)
 Default Alias: Cache
 Alias: Cache
 Alias: cache
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: cache
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
Action: Void CompilePbix(System.String, System.String, PbiTools.PowerBI.PbiFileFormat, Boolean)
 Default Alias: CompilePbix
 Alias: CompilePbix
 Alias: compile
 Alias: compile-pbix
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: compile
 Shortcut: compile-pbix
 Metadata: PowerArgs.ArgDescription
Action: Void Convert(System.String, System.String, PbiTools.ProjectSystem.ModelSerializationMode, PbiTools.ProjectSystem.MashupSerializationMode, System.String, Boolean, Boolean, Boolean)
 Default Alias: Convert
 Alias: Convert
 Alias: convert
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: convert
 Metadata: PowerArgs.ArgDescription
Action: Void Deploy(System.String, System.String, System.String, System.String, Boolean)
 Default Alias: Deploy
 Alias: Deploy
 Alias: deploy
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: deploy
 Metadata: PowerArgs.ArgDescription
Action: Void ExportData(Int32, System.String, System.String, System.String)
 Default Alias: ExportData
 Alias: ExportData
 Alias: export-data
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: export-data
 Metadata: PbiTools.Cli.ArgAltShortcut
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
 Metadata: PowerArgs.ArgExample
Action: Void ExportUsage(System.String)
 Default Alias: ExportUsage
 Alias: ExportUsage
 Alias: export-usage
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: export-usage
 Metadata: PowerArgs.OmitFromUsageDocs
Action: Void Extract(System.String, Int32, System.String, PbiTools.Cli.ExtractActionCompatibilityMode, PbiTools.ProjectSystem.ModelSerializationMode, PbiTools.ProjectSystem.MashupSerializationMode)
 Default Alias: Extract
 Alias: Extract
 Alias: extract
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: extract
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
 Metadata: PowerArgs.ArgExample
Action: Void GenerateBim(System.String, Boolean, PbiTools.Cli.ExportTransforms)
 Default Alias: GenerateBim
 Alias: GenerateBim
 Alias: generate-bim
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: generate-bim
 Metadata: PbiTools.Cli.ArgAltShortcut
 Metadata: PowerArgs.ArgDescription
Action: Void Git(PbiTools.Cli.GitAction)
 Default Alias: Git
 Alias: Git
 Alias: git
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: git
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
Action: Void Info(Boolean)
 Default Alias: Info
 Alias: Info
 Alias: info
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: info
 Metadata: PowerArgs.ArgDescription
 Metadata: PowerArgs.ArgExample
Action: Void Init(PbiTools.Cli.InitAction, System.String)
 Default Alias: Init
 Alias: Init
 Alias: init
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: init
 Metadata: PowerArgs.ArgDescription
Action: Void LaunchPbiDesktop(System.String)
 Default Alias: LaunchPbiDesktop
 Alias: LaunchPbiDesktop
 Alias: launch-pbi
 Metadata: PowerArgs.ArgActionMethod
 Shortcut: launch-pbi
 Metadata: PowerArgs.ArgDescription
'RemoveAutoAliases' invoked. Caller: BeforeValidateDefinition
Invoking Action: extract(Aliases=1)(Arguments=6)
Attempting to resolve assembly: Microsoft.PowerBI.Packaging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Using Power BI Desktop install: 2.100.1401.0 (21.12) at C:\Program Files\Microsoft Power BI Desktop\bin
Assembly 'Microsoft.PowerBI.Packaging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' found at C:\Program Files\Microsoft Power BI Desktop\bin\Microsoft.PowerBI.Packaging.dll
Reading PbixModel from file at C:\Projects\pbitools\test.pbix (Version: 1.25)
Reading Connections...
Reading Report...
Reading DiagramLayout...
Reading DiagramViewState...
Reading LinguisticSchemaXml...
Reading LinguisticSchema...
Reading ReportMetadata...
Reading ReportSettings...
Reading CustomVisuals...
Reading StaticResources...
Reading DataModel...
MSMDSRV.EXE found at C:\Program Files\Microsoft Power BI Desktop\bin\msmdsrv.exe
Working directory: C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp
<ConfigurationSettings>
  <TMCompatibilitySKU>0</TMCompatibilitySKU>
  <RecoveryModel>1</RecoveryModel>
  <DisklessModeRequested>1</DisklessModeRequested>
  <InstanceVisible>0</InstanceVisible>
  <AllowedBrowsingFolders>C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp</AllowedBrowsingFolders>
  <Language>8192</Language>
  <Port>0</Port>
  <PrivateProcess>27876</PrivateProcess>
  <BackupDir>C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp</BackupDir>
  <LogDir>C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp</LogDir>
  <TempDir>C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp</TempDir>
  <DataDir>C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp</DataDir>
  <DeploymentMode>1</DeploymentMode>
  <CleanDataFolderOnStartup>1</CleanDataFolderOnStartup>
  <AutoSetDefaultInitialCatalog>1</AutoSetDefaultInitialCatalog>
  <Network>
    <ListenOnlyOnLocalConnections>1</ListenOnlyOnLocalConnections>
    <Requests>
      <EnableBinaryXML>1</EnableBinaryXML>
      <EnableCompression>1</EnableCompression>
    </Requests>
    <Responses>
      <EnableBinaryXML>1</EnableBinaryXML>
      <EnableCompression>1</EnableCompression>
      <CompressionLevel>9</CompressionLevel>
    </Responses>
  </Network>
  <Debug>
    <CallStackInError>0</CallStackInError>
  </Debug>
  <Log>
    <Exception>
      <CrashReportsFolder>C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp</CrashReportsFolder>
    </Exception>
    <Trace>
      <TraceFileBufferSize>128</TraceFileBufferSize>
    </Trace>
    <FlightRecorder>
      <Enabled>1</Enabled>
      <FileSizeMB>50</FileSizeMB>
      <LogDurationSec>36000</LogDurationSec>
    </FlightRecorder>
  </Log>
  <Memory>
    <MemoryHeapType>5</MemoryHeapType>
  </Memory>
  <ResourceGovernance>
    <GovernIMBIScheduler>0</GovernIMBIScheduler>
  </ResourceGovernance>
  <Feature>
    <ManagedCodeEnabled>1</ManagedCodeEnabled>
    <MEngineTracingEnabled>0</MEngineTracingEnabled>
    <UseXPress9Compression>1</UseXPress9Compression>
    <SkipXPress9CompressionSizeMB>0</SkipXPress9CompressionSizeMB>
    <CompositeModel>1</CompositeModel>
    <ManyToManyRelationship>1</ManyToManyRelationship>
    <EnableIncrementalRefresh>1</EnableIncrementalRefresh>
    <ASQLAggEnabled>0</ASQLAggEnabled>
    <ASQLAggRLSEnabled>0</ASQLAggRLSEnabled>
    <WholesaleDax>0</WholesaleDax>
    <DataSourceReferenceEnabled>2</DataSourceReferenceEnabled>
    <EnableMDQV3>1</EnableMDQV3>
  </Feature>
  <VertiPaq>
    <EnableDisklessTMImageSave>1</EnableDisklessTMImageSave>
    <EnableProcessingSimplifiedLocks>1</EnableProcessingSimplifiedLocks>
    <ImageLoadStreamBufferMB>2147483647</ImageLoadStreamBufferMB>
  </VertiPaq>
  <DAX>
    <EnableVariationNotation>1</EnableVariationNotation>
    <DQ>
      <EnableAllFunctions>1</EnableAllFunctions>
      <SelectCartridgeUsingConnectionString>0</SelectCartridgeUsingConnectionString>
    </DQ>
  </DAX>
</ConfigurationSettings>
Started MSMDSRV, PID: 1216
MSMDSRV ERR: null
MSMDSRV INF: null
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp\msmdsrv.bak
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp\msmdsrv.ini
Deleting file C:\Users\JanMechtel\AppData\Local\Temp\tmp21E7.tmp\msmdsrv_Failed_ini.bak
An unhandled exception occurred.
System.Exception: Process has terminated
   at PbiTools.PowerBI.AnalysisServicesServer.Start() in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\PowerBI\AnalysisServicesServer.cs:line 145
   at PbiTools.PowerBI.DataModelConverter.LaunchTabularServerAndExecuteCallback[T](Func`2 callback) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\PowerBI\DataModelConverter.cs:line 82
   at PbiTools.Model.PbixModel.FromReader(PbixReader reader, String targetFolder, Nullable`1 portNumber) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Model\PbixModel.cs:line 168
   at PbiTools.Cli.CmdLineActions.Extract(String pbixPath, Int32 pbiPort, String extractFolder, ExtractActionCompatibilityMode mode, ModelSerializationMode modelSerialization, MashupSerializationMode mashupSerialization) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Cli\Extract.cs:line 63
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at PowerArgs.ArgAction.Invoke()
   at PbiTools.Program.Main(String[] args) in X:\pbi-tools\pbi-tools-cli\src\PBI-Tools\Program.cs:line 82
mthierba commented 2 years ago

Uhm....

Your msmdsrv is actually coming from the MSI installer location: C:\Program Files\Microsoft Power BI Desktop\bin. Which means the temp copy directory is not relevant.

That same file opens fine in PBI Desktop?

Could you try to run the extract on any of the files here: https://github.com/microsoft/powerbi-desktop-samples/tree/main/Monthly%20Desktop%20Blog%20Samples

janmechtel commented 2 years ago

I'm new to msmdsrv.exe and a bit puzzled.

image

mthierba commented 2 years ago

The directory given on the -s arg needs to have a msmdsrv ini file in it. Open PBI Desktop and run pbi-tools info - that'll list the current pbiSession including the msmdsrv working directory. Open that one up in explorer - it'll have the ini file (generated by PBI Desktop).

janmechtel commented 2 years ago

Ok, I'll give it a try and seed them.

It looked like when the directory is empty msmdsrv actually creates some msmdsrv.ini + msmdsrv.bak in there. image

Also I'll try on a different machine, maybe that works.

mthierba commented 2 years ago

The auto-generated ini won't be sufficient to open PBI models. It needs to be the one provided by PBI Desktop or pbi-tools (template: https://github.com/pbi-tools/pbi-tools/blob/main/src/PBI-Tools/PowerBI/msmdsrv.ini.xml). Ultimately, this is replicating exactly what PBI Desktop does when opening a pbix with an embedded model.

janmechtel commented 2 years ago

I can try with a different ini file. I'm just surprised that there is no meaningful output / msmdsrv.exe doesn't show up in my process list yet at all.

janmechtel commented 2 years ago

So loading msmdsrv.exe with an existing ini directory (as being use bei PowerBI Desktop works fine).

.\msmdsrv.exe -c -n test -s "C:\\Users\\JanMechtel\\AppData\\Local\\Microsoft\\Power BI Desktop\\AnalysisServicesWorkspaces\\AnalysisServicesWorkspace_3639451b-b082-4c09-99b3-633bc2c85f00\\Data"`

Will show meaningful output and the process is visible in Task manager

janmechtel commented 2 years ago

I'll try to see if I can observe the ini that pbi-tools are supposed to put into the _tempDirectory

Is there a way to change the working directory?

janmechtel commented 2 years ago

Your msmdsrv is actually coming from the MSI installer location: C:\Program Files\Microsoft Power BI Desktop\bin. Which means the temp copy directory is not relevant.

How should I understand this here:

// Start new instance
// '-n' arg is REQUIRED for dynamic port assignment! -- will only use default port 2383 otherwise (and fail if that port is in use)
var procStartInfo = new ProcessStartInfo(_asToolPath, $"-c -n {Guid.NewGuid()} -s \"{_tempPath}\"")
{
    WorkingDirectory = _tempPath,
};

On first glance it looks like it's setting the folder to the temp working directory.

mthierba commented 2 years ago

Those files get auto deleted as soon as the msmdsrv process exits (even when it fails). But I could provide a private build which doesn't do that.

janmechtel commented 2 years ago

If you like I can also try to build myself, in case you want some battle testing for the build instructions?

It's been a while since i did anything with VS Studio though. Might be more work than help.

janmechtel commented 2 years ago

So quick update, my other machine works fine. Even with the Power BI Desktop version from the store :-/

Maybe I should restart and try again on this machine.

mthierba commented 2 years ago

Just pushed a new branch with some debug enhancements to https://github.com/pbi-tools/pbi-tools/tree/Issues/78-MT (accidentally also pushed it to main... SILLY!)

This one allows you to set a new environment variable PBITOOLS_Debug:

$env:PBITOOLS_Debug = "1"

The effect of that is twofold:

Checkout the branch and build with:

.\build.cmd Publish

That'll create the exe in ./.build/dist/desktop for you to try.

(I've just seen your previous note!)

janmechtel commented 2 years ago

So building worked and I debug now.

First observation is that there is msmdsrv_Failed_ini.bak visible (before all of the files get deleted).

I believe it's written after pbi-tools attempts to run the process msmdsrv.

I've also tried to make the process window visible but it only flashes.

Now I'll try to get the exact command of the process that pbi-tools would run and then try to run that manually.

janmechtel commented 2 years ago

Running it manually doesn't do much

PS C:\Program Files\Microsoft Power BI Desktop\bin> .\msmdsrv.exe -c -n b4169ac5-21ea-4ac8-863b-c32ed4864eb0 -s "C:\\Users\\JanMechtel\\AppData\\Local\\Temp\\tmpFA8A.tmp"
-c -n b4169ac5-21ea-4ac8-863b-c32ed4864eb0 -s C:\\Users\\JanMechtel\\AppData\\Local\\Temp\\tmpFA8A.tmp
Server instance name MSOLAP$b4169ac5-21ea-4ac8-863b-c32ed4864eb0

Neither the _Failed.bak is written, nor does the process show up in task manager.

janmechtel commented 2 years ago

Ok, I'll check it out now.

mthierba commented 2 years ago

msmdsrv aims to attach itself to a parent process. A valid process ID needs to be specified in msmdsrv.ini before launching it:

image

Would grab the ID from your cmd window, for instance.

pbi-tools inserts its own proc id in there when it writes the ini.

janmechtel commented 2 years ago

No dice yet, but indeed the temp directory is the local directory now.

PS C:\Users\JanMechtel> cd C:\Projects\pbitools\pbitools\.build\dist\desktop
PS C:\Projects\pbitools\pbitools\.build\dist\desktop> $env:PBITOOLS_Debug = "1"
PS C:\Projects\pbitools\pbitools\.build\dist\desktop> .\pbi-tools.exe extract ".\test.pbix"
Using Power BI Desktop install: 2.100.1401.0 (21.12) at C:\Program Files\Microsoft Power BI Desktop\bin
MSMDSRV.EXE found at C:\Program Files\Microsoft Power BI Desktop\bin\msmdsrv.exe
Working directory: C:\Projects\pbitools\pbitools\.build\dist\desktop
An unhandled exception occurred.
System.Exception: Process has terminated
   at PbiTools.PowerBI.AnalysisServicesServer.Start() in C:\Projects\pbitools\pbitools\src\PBI-Tools\PowerBI\AnalysisServicesServer.cs:line 150
   at PbiTools.PowerBI.DataModelConverter.LaunchTabularServerAndExecuteCallback[T](Func`2 callback) in C:\Projects\pbitools\pbitools\src\PBI-Tools\PowerBI\DataModelConverter.cs:line 82
   at PbiTools.Model.PbixModel.FromReader(PbixReader reader, String targetFolder, Nullable`1 portNumber) in C:\Projects\pbitools\pbitools\src\PBI-Tools\Model\PbixModel.cs:line 168
   at PbiTools.Cli.CmdLineActions.Extract(String pbixPath, Int32 pbiPort, String extractFolder, ExtractActionCompatibilityMode mode, ModelSerializationMode modelSerialization, MashupSerializationMode mashupSerialization) in C:\Projects\pbitools\pbitools\src\PBI-Tools\Cli\Extract.cs:line 63
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at PowerArgs.ArgAction.Invoke()
   at PbiTools.Program.Main(String[] args) in C:\Projects\pbitools\pbitools\src\PBI-Tools\Program.cs:line 82
PS C:\Projects\pbitools\pbitools\.build\dist\desktop
janmechtel commented 2 years ago

I go for the restart before we waste the whole night.

janmechtel commented 2 years ago

After restart and same problem. I've attempted to put the process id from my current powershell into the msmdsrv.ini but it results in the same behavior:

I'll check if there is a "verbose" mode for msmdsrv.exe

janmechtel commented 2 years ago

Everything indicates that the .ini is wrong/broken. Maybe I should diff with a working ini from my other machine. Unfortunately it's hard to grab there + I don't have Visual Studio there. Could you maybe send me a working ini?

janmechtel commented 2 years ago

When I replace the msmdsrv.ini written by the tool with a working .ini file inside the folder while debugging/breaking then the msmdsrv.exe will launch and produce output.

To me it still looks like the .ini is somehow broken. I didn't find a verbose mode to have msmdsrv.exe say what's wrong with it though.

mthierba commented 2 years ago

This is a real-world ini: https://github.com/pbi-tools/pbi-tools/blob/Issues/78-MT/data/msmdsrv/msmdsrv.ini

janmechtel commented 2 years ago

Thanks, I think I found a clue. I went through the msmdsrv.ini written by the tool and found this line:

<Language>8192</Language>

I was curious whether language would matter and lo-and-behold removing the line makes the process start and stay open.

Now I'm trying to figure out how this line is written into the .ini because it doesn't seem to be in the Template msmdsrv.ini.xml

janmechtel commented 2 years ago

So this gets/sets the Language public int Language { get; set; } = CultureInfo.CurrentCulture.LCID;

On my machine it's 8192 but Power BI Desktop msmdsrv.ini are using 1033.

Oddly enough 8192 seems to be unknown to microsoft and google search produces quite some errors. This is probably something weird with my machine. I guess I can use my own build for now and you consider doing something about it if somebody else runs into the problem?

janmechtel commented 2 years ago

Otherwise I don't know if you already have a place where we could overwrite the .xml config?

Or I could simply submit a pull request to switch to 1033 in the case of 8192?

Thanks for getting me this far anyways. Have a good night.

mthierba commented 2 years ago

That's really awesome work, thanks for being so persistent! I wonder whether 1033 would be a safe fallback for anyone? Annoying that msmdsrv would simply fail silently! One other thing to try could be set Language to '0', some of the settings take that as a default value.

janmechtel commented 2 years ago

I mean in my debugging, even removing the line completely worked.

So maybe I can skip the language if it's set to 8192 which is unknown to microsoft?

mthierba commented 2 years ago

@janmechtel Would you mind testing with a new build from the latest changes in https://github.com/pbi-tools/pbi-tools/tree/Issues/78-MT ? This one resets Language to 0 for everyone, which may well be sufficient.

janmechtel commented 2 years ago

Works like a charm :-)

janmechtel commented 2 years ago

We should keep in mind that msmdsrv_FAILED_ini.bak in the temp folder indicates that msmdsrv.exe was unable to start probably because of the config.

mthierba commented 2 years ago

We should keep in mind that msmdsrv_FAILED_ini.bak in the temp folder indicates that msmdsrv.exe was unable to start probably because of the config.

Good point - the tool could detect that condition, emit a descriptive error, and skip deleting the temp folder (instead, tell the user where it is.) Feel like doing a PR?

mthierba commented 2 years ago

Fix for this is now available in interim release: https://github.com/pbi-tools/pbi-tools/releases/tag/1.0.0-beta.9%2B220202

Thanks again @janmechtel for extensive help here!

Khushi186 commented 1 year ago

Hello @mthierba , I am following this video PBI-Tools Part 1 - Introduction and Setup (https://www.youtube.com/watch?v=6zyvtxJSoyA&list=PLzN99cpDw6oA6nQuteFG0ycDI7MfVxy9s&index=1) and tried to follow the same. But I am getting this error. Can you please help me out why this is happening? PS C:\PBI_Automation\RDA-PowerBI-Reports> pbi-tools deploy . Files PROD -whatif Reading PBIXPROJ settings from: C:\PBI_Automation\RDA-PowerBI-Reports.pbixproj.json === Deployment WhatIf mode enabled === An unhandled exception occurred. System.AggregateException: One or more errors occurred. ---> PbiTools.Deployments.DeploymentException: The current project does not contain the specified deploymment 'Files' at PbiTools.Deployments.DeploymentManager.d__30.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at PbiTools.Cli.CmdLineActions.Deploy(String folder, String label, String environment, String basePath, Boolean whatIf) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at PowerArgs.ArgAction.Invoke() at PbiTools.Program.Main(String[] args)

mthierba commented 1 year ago

Hi,

your command (pbi-tools deploy . Files PROD) assumes that your .pbixproj.json manifest file contains a deployment manifest called "Files" and an environment called "PROD". Looking at the error message, it appears that in your case the manifest label is something other than "Files".

This example uses "Files" for the manifest and "Development" for the environment:

image

Khushi186 commented 1 year ago

Thanks @mthierba for your quick reply. Sorry I did not get it properly. I am a beginner of using Git. Can you help me out to solve this? Is it possible to share the previous step? Like What is "Files" here and what do I really need to do with this? Step from the beginning that can help me out to resolve this issue. Thanks

Khushi186 commented 1 year ago

Hello @mthierba, I have resolved that issue by providing pbix filename. Now it is saying that deployment completed successfully but when I checked my workspace, pbix file is not deployed. Any suggestion, how to resolve this? image

mthierba commented 1 year ago

@Khushi186 Running pbi-tools deploy with the -whatif toggle will explicitly only perform a test/validation run without actually modifying any of your workspaces. Drop the -whatif from the command-line and it should go through.

Khushi186 commented 1 year ago

Thanks, Tested it locally, its working now.

Khushi186 commented 1 year ago

Hello @mthierba Workflow was running properly but now I am getting this error while deploying the Reports. It seems related to authentication of APIs, but not sure. Can you please help me what's going wrong here? image Thanks

mthierba commented 1 year ago

Your service principal is not sufficiently set up.

There are a few prerequisites you should check:

  1. Your Azure AD service principals should NOT have any Power BI Application Permissions selected

image

  1. In your Power BI Admin portal, service principal access needs to be enabled for the tenant. Ideally, scoped to specific security groups (one of which your service principal needs to belong to).

image

The screenshot shows some broken labels - this currently applies to many PBI tenants while some backend updates are being rolled out.

  1. The service principal you're using for the deployment needs to have access to your target workspace(s), with Contributor or Member permissions.

image

With those three settings in place things should work well!

Khushi186 commented 1 year ago

I have added these permissions in service principal as an Delegated Permissions, not Application Permissions. image I don't think delegated one will be an issue. Correct ? and Step 2 and Step 3 are already in Place.